I am new to VB6 (and visual basic in any form) development and I've come across a problem. There may be lexical errors below because I formatted the code to be a little more readable inside of the post here, but the essence of the question remains. Here is the code
My problem is that the values displayed by the MsgBox calls (the second set of them, the ones that reference the variables scrWord and resWord) differ depending on when I assign to the variables scrWord and resWord. If I assign to the variables scrWord and resWord in the first location that is uncommented in the code shown above, then the message boxes at the bottom of the code will print either strings I am not interested in (for example, the first messagebox will produce an output looking like "srcws:resColNum:#") or what appears to be garbage data. Note that this means it assigned a static string I used in the previous message box to the variable scrWord. This is NEVER the intended behavior and I have no idea how it is happening.
If, on the other hand, the assignment is done immediately before the message boxes, where the variable assignment is commented in the code above, then the variables print a different value that is somewhat more like what is expected, but not exactly (typically, the two variables are exactly the same or one is numeric when both are expected to be different alpha strings).
I am baffled by this problem and I believe it has something to do with the GetData calls returning a Variant data type.
Thank you, Evan
New code is posted below. Still doesn't work.
Dim srcWord As Variant
Dim resWord As Variant
Do While (BinsCol.GetData(grouprownum, 1) = binfromnum And nogroupfound = True)
Dim groupmismatch As Boolean
groupmismatch = False
For j = 1 To FormHyst.GroupList.ListCount
srcWord = sourceWS.Columns(j).GetData(i, 1)
resWord = "hello, world"
MsgBox ("srcws:" & srcWord & vbNewLine &_
"resws:" & resWord & vbNewLine &_
"test:" & (resWord <> srcWord))
Next
Loop
In this new code, both srcWord and resWord display "hello, world".
I still cannot make sense of this behavior.