Sending strings to Listboxes

J

JimmyX

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

Armin Zingler

JimmyX said:
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
 
R

rowe_newsgroups

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
 
J

JimmyX via DotNetMonster.com

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 said:
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
 
A

Armin Zingler

JimmyX via DotNetMonster.com said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top