Why does it add two items?

  • Thread starter Thread starter Stapes
  • Start date Start date
S

Stapes

Hi

I have the following line of code:

ctrlListBox.AddItem Item:=strItem

However, where the value of strItem contains a comma, such as KOREA,
DEMOCRATIC PEOPLE'S REP, it comes out as two separate items, KOREA and
DEMOCRATIC PEOPLE'S REP.

Why is this? How can I prevent it?

Stapes
 
Stapes said:
Hi

I have the following line of code:

ctrlListBox.AddItem Item:=strItem

However, where the value of strItem contains a comma, such as KOREA,
DEMOCRATIC PEOPLE'S REP, it comes out as two separate items, KOREA and
DEMOCRATIC PEOPLE'S REP.

Why is this? How can I prevent it?


Because the list box uses the comma as a value-separator in its rowsource,
you must enclose the value to be added in quotes (single or double) when you
add it, if it contains (or may contain) a comma:

ctrlListBox.AddItem Item:=Chr(34) & strItem & Chr(34)
 

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

Back
Top