
Stange String Behavior - Bug or Bugged ?
Bug - System placed the bug.
Bugged - I placed the bug.
When concatentationg strings, results are not as expected.
s1 = .CompKey
s2 = .CompDescr
s3 = s1&s2
Expected result for s3 = 123ABC
Actual Result for s3 = 123
Here is the actual code.
Function getCompanyKeyList() As Collection
Dim myCompanyKeys As New Collection()
Dim s1 As String
Dim s2 As String
Dim s3 As String
If Not isCompanyOpen Then
openCompanyFile() ' Open the company file if not open
getFirstCompany()
Else
getFirstCompany()
End If
Do Until Bstat = 9 Or Bstat <> 0 'Loop through company records
With appRecord
If .CompDefault Then
gDEFAULTCOMP = .CompKey
End If
s1 = .CompKey
s2 = .CompDescr
s3 = Trim(s1) & " - " & Trim(s2)
myCompanyKeys.Add(Trim(s3), s2) ' Add company to collection
End With
getNextCompany() 'Get the next company record
Loop
Return myCompanyKeys ' Return collection to caller
End Function
Note: s1 and s2 are updated correctly. The update to s3 only gets the value
of s1 and not the concatenation of " - " & s2.
If I hard code the vlaues then it works. So there must be something I am
missing about the data types I'm working with. Or there is a bug I need to
avoid?
The data for all variables has been verified via de{*filter*}. It's the update
to s3 that fails which also casues the addition to the collection to fail.
Any clues as to why this is happening?
tia,
Todd