Stange String Behavior - Bug or Bugged ? 
Author Message
 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



Thu, 26 May 2005 04:39:38 GMT  
 Stange String Behavior - Bug or Bugged ?
I don't see what the problem is, but have you tried removing the With block?
I avoid them since I can't do a quick watch on ".CompKey". Have you tried
removing the Trim functions? If you have 's3 = s1 & " - " & s2', does it
work? If not, do a quick watch on 's1 & " - " & s2'. Is the result right?
It's probably a stupid error somewhere.


Quote:
> 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



Thu, 26 May 2005 12:43:00 GMT  
 Stange String Behavior - Bug or Bugged ?
Ettienne,
Thanks for the help.
It turns out that the file was being corrupted from another routine not
marshalling booleans correctly.
Boolean values ended up being FF instead of 01. As soon as I rebuilt the
file it worked fine.

Thanks
Todd


Quote:
> I don't see what the problem is, but have you tried removing the With
block?
> I avoid them since I can't do a quick watch on ".CompKey". Have you tried
> removing the Trim functions? If you have 's3 = s1 & " - " & s2', does it
> work? If not, do a quick watch on 's1 & " - " & s2'. Is the result right?
> It's probably a stupid error somewhere.



> > 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



Fri, 27 May 2005 00:56:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. IDE BUGs, BUGs, BUGs....

2. BUGS BUGS BUGS!

3. Project98 OLE & VB: bugs, bugs, bugs

4. Is it bug or an intended behavior?

5. Is it bug or the intended behavior...

6. weird dataview behavior or a possible bug

7. MS Jet 4.0 - bug or behavior by design?

8. ActiveX Control.Count bug, or wierd behavior

9. vb bug with TitleBar behavior?

10. Listview strange behavior (bug?)

11. ListView: Strange Behavior...not really a bug though.

12. MS Jet 4.0 - bug or behavior by design?

 

 
Powered by phpBB® Forum Software