By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,627 Members | 1,870 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,627 IT Pros & Developers. It's quick & easy.

Sending strings to Listboxes

P: n/a
If I try to add a string to a string variable and display it in a listbox,
the string does not display

Strng="abc"
listbox1.items.add(Strng+"xyz")

The resulting display is abc

But if I do it the other way around:
Strng="abc"
listbox1.items.add("xyz"+Strng)

It displays correctly
The resulting display is xyzabc

Why does this happen???????

Oct 3 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"JimmyX" <u37963@uweschrieb
If I try to add a string to a string variable and display it in a
listbox, the string does not display

Strng="abc"
listbox1.items.add(Strng+"xyz")

The resulting display is abc

But if I do it the other way around:
Strng="abc"
listbox1.items.add("xyz"+Strng)

It displays correctly
The resulting display is xyzabc

Why does this happen???????
Apart from the fact that the & operator should be used to concatenate
strings, I can not reproduce the problem. First code gives "abcxyz".
Armin

Oct 4 '07 #2

P: n/a
On Oct 3, 6:31 pm, "JimmyX" <u37963@uwewrote:
If I try to add a string to a string variable and display it in a listbox,
the string does not display

Strng="abc"
listbox1.items.add(Strng+"xyz")

The resulting display is abc

But if I do it the other way around:
Strng="abc"
listbox1.items.add("xyz"+Strng)

It displays correctly
The resulting display is xyzabc

Why does this happen???????
First off, do you have Option Explicit On? Or did you just not share
with use the declaration for the variable Strng?

Thanks,

Seth Rowe

Oct 4 '07 #3

P: n/a
Option Explicit is on. Since I posted this e-mail, I noticed that some string
variables don't cause this
problem. The string cvariable that I'm using is in an array and was read as
Bytes from a binary file.

rowe_newsgroups wrote:
>If I try to add a string to a string variable and display it in a listbox,
the string does not display
[quoted text clipped - 12 lines]
>>
Why does this happen???????

First off, do you have Option Explicit On? Or did you just not share
with use the declaration for the variable Strng?

Thanks,

Seth Rowe
--
Message posted via http://www.dotnetmonster.com

Oct 4 '07 #4

P: n/a
"JimmyX via DotNetMonster.com" <u37963@uweschrieb
Option Explicit is on. Since I posted this e-mail, I noticed that
some string variables don't cause this
problem. The string cvariable that I'm using is in an array and was
read as Bytes from a binary file.
Probably there is a chr(0) in it.
Armin
Oct 4 '07 #5

P: n/a
That was the problem! Thanks so much for your help.

Jimmy

Armin Zingler wrote:
>Option Explicit is on. Since I posted this e-mail, I noticed that
some string variables don't cause this
problem. The string cvariable that I'm using is in an array and was
read as Bytes from a binary file.

Probably there is a chr(0) in it.

Armin
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200710/1

Oct 7 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.