I'm new to VB6 development (and Visual Basic in any form), and I ran into a problem. There may be lexical errors below, because I formatted the code to be more readable inside the message 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, those that reference the scrWord and resWord variables) differ depending on when I assign the scrWord and resWord variables. If I assign scrWord and resWord to the variables at the first location, which is not indicated in the code shown above, then the message blocks at the bottom of the code will print lines that do not interest me (for example, the first message will produce an output that looks like "srcws: resColNum: # ") or what seems like garbage. Note that this means that she assigned the static string that I used in the previous message box to the variable variable scrWord. This is NEVER the intended behavior, and I have no idea how this happens.
If, on the other hand, the assignment is performed immediately before messages where the assignment of a variable is commented on in the code above, then the variables print a different value, which is somewhat more similar to what is expected, but not exact (as a rule, the two variables are exactly the same or one numeric, when both must be different alpha strings).
I am puzzled by this problem, and I believe that it has something to do with GetData calls that return a Variant data type.
Thanks Evan
The new code is posted below. Still not working.
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 understand this behavior.
Evan
source
share