Adding a string to a listbox with a comma in it?

texuspete00

Supreme [H]ardness
Joined
Sep 9, 2002
Messages
5,625
Really bizarre this behaves the way it does. I am used to dealing with funky stuff for quotation marks because it's an exit string character, but a comma in the middle of a string? WTF!

Rather than mess with my code and variables, I did straight up tests.

ie. ListBox.AddItem ("Burke, Joe")

That makes two entries- one Burke, the other Joe, even though if that's what I wanted, it really should be

ListBox.AddItem ("Burke" , "Joe")

Double comma would give me a blank entry in between the other two! I mean what the fiddlesticks! I dunno. Laugh at my expense. One of the wonkier things I've seen it do. Makes zero sense.
 
Sorry guys, just VBA. I assumed VB would be the same. Wasn't thinking, how there would be some confusion in regards to .Net.
 
I am not too familiar with vb, but I think if you do something like this it might work:

ListBox.AddItem ("Burke"&chr(44)&" Joe")
 
Yeah, I think I might give something like that a shot. Thing is this was just a test. Normaly there would just be a single variable. 99% of the time, it won't have a comma. I guess I can parse it up into an array or somthing. Store the location of every comma, so I can piece it back together like that with Chr() in place of commas. I'm kind of a noobie.
 
Or maybe you can do an explicit cast with CStr().
 
What a coincidence... My address book shows 2 "Joe Burkes" working at my company.

 
You might want to try putting it in single quotes, so

ListBox.AddItem ('Burke, Joe')

I know in PHP that double quote makes the program process variables, and if it reads commas as a variable, then that could be what's happening, but with single quotes, it doesn't process the string at all.
 
Back
Top