View Full Version : Solved: listbox items as variables
mpearce
06-18-2010, 12:33 PM
i have a listbox containing 4 items. how can i store each individual item in a variable?
Tinbendr
06-18-2010, 01:31 PM
The long way.
Dim A As String
Dim B As String
Dim C As String
Dim D As String
A = ListBox1.List(0)
B = ListBox1.List(1)
C = ListBox1.List(2)
D = ListBox1.List(3)
The short way.
Dim LBItem As Long
For LBItem = 0 To ListBox1.ListCount - 1
MsgBox ListBox1.List(LBItem)
Next
Norie
06-20-2010, 12:02 PM
Even shorter, though it does use an array.
arr = Listbox1.List
mikerickson
06-20-2010, 09:17 PM
The .List of a ListBox is a 10 column array (unless set larger with the column
ala Dim Arr(0 to (.ListCount-1), 0 to 9)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.