English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm looking to cycle through items in a listbox and output each item into a messagebox. So, for example. I have a listbox which contains the values Apple and Orange one after the other. What I want to do is have two message boxes display upon clicking a button which will display 'Apple' in the first messagebox then 'Orange' in the second. The amount of entries in the list could vary so I would need it to loop through until all the entries had been outputted to msgboxes.

2006-11-22 01:21:42 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

You don't need two msgboxes.

for intCounter = 0 to lstListBox.Listcount-1
msgbox lstListBox.List(intCounter)
next intCounter

that should do it.

2006-11-22 01:26:27 · answer #1 · answered by timc_fla 5 · 1 0

dim previous as string
dim current as string
dim ctr as integer

previous = ""

for ctr = 0 to lstMessages.Count -1

if ctr > 0 then previous = lstMessages.List(ctr - 1)
current = lstMessages.List(ctr)

msgbox(previous) 'display the previous one
msgbox(current) 'display the current item

next



'something like that????

2006-11-22 02:13:38 · answer #2 · answered by Tamayi M 2 · 0 0

fedest.com, questions and answers