LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Listbox text property not working correctly

I am using Excel 2002. I have created a form with 4 listboxes all
populated with For..Next loops during the Userform Initialize
procedure.

I then select an item in each listbox using listbox1.listindex = xx.

I then try to access the selected items using listbox.text and display
the results in a message box.

I only receive the correct answer for two listboxes. The other two
listboxes (not always the same two listboxes) appear to be empty. (See
example code below.)

Private Sub UserForm_Initialize()
Dim x As Integer

For x = 1 To 50
With ListBox1
.AddItem "Number " & x
End With
Next x
For x = 1 To 50
With ListBox2
.AddItem "Number " & x
End With
Next x
For x = 1 To 50
With ListBox3
.AddItem "Number " & x
End With
Next x
For x = 1 To 50
With ListBox4
.AddItem "Number " & x
End With
Next x

With UserForm1
.ListBox1.ListIndex = 30
.ListBox2.ListIndex = 31
.ListBox3.ListIndex = 32
.ListBox4.ListIndex = 33
End With

MsgBox "Box 1 = " & ListBox1.Text & Chr(13) & "Box 2 = " &
ListBox2.Text & Chr(13)
MsgBox "Box 3 = " & ListBox3.Text & Chr(13) & "Box 4 = " &
ListBox4.Text & Chr(13)

End Sub

Any help would be greatly appreciated.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If function not working correctly Relle Excel Discussion (Misc queries) 10 September 16th 09 10:42 AM
Filters not working correctly EZ Setting up and Configuration of Excel 1 September 1st 08 05:15 PM
VLookup is not working correctly Eric @ BP-EVV Excel Worksheet Functions 3 July 18th 08 12:24 AM
Wrap Text is not working correctly on one persons computer bocikt Excel Discussion (Misc queries) 16 May 22nd 07 04:09 AM
Text to Columns not working correctly with dates in Excel 2007 AL123 Excel Discussion (Misc queries) 5 February 26th 07 11:44 PM


All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"