PDA

View Full Version : Solved: Bonus question



WebGuy
07-13-2006, 04:43 AM
Hi Again !
This is a continuation of the "Make a structured list in a textbox. " thread.
I have a bonus question. I have integrated the listbox system into my Server program , but i would like the listbox2 servers to be stored in an array rather than as a string.
This is probably very simple for the most of you , but it would help me immensly (and make me look like an expert to my boss).

here is a bit of code.


UserForm2.ListBox1.List = colsarray()
UserForm2.Show vbModal
Textstring = ""
For counter = 1 To UserForm2.ListBox2.ListCount
Textstring = Textstring + UserForm2.ListBox2.List(counter - 1) & vbCrLf
ServerList(counter) = UserForm2.ListBox2.List(counter - 1) '*******
Next


The row marked by "*" is the one i am having trouble with...

thanks !

Bob Phillips
07-13-2006, 05:02 AM
With UserForm2
.ListBox1.List = colsarray()
.Show vbModal
Textstring = ""
ReDim colsarray(1 To 1)
For counter = 1 To .ListBox2.ListCount
Textstring = Textstring + .ListBox2.List(counter - 1) & vbCrLf
ReDim Preserve ServerList(1 To counter)
ServerList(counter) = .ListBox2.List(counter - 1)
Next
End With

mdmackillop
07-13-2006, 05:12 AM
I've tweaked my eample a little to upload sample code

Option Explicit
Private Sub CommandButton1_Click()
Dim serverlist, s, Textstring As String, Counter As Long
UserForm2.ListBox2.List = (Range("colsarray"))
Textstring = ""
ReDim serverlist(UserForm2.ListBox2.ListCount)
For Counter = 1 To UserForm2.ListBox2.ListCount
Textstring = Textstring + UserForm2.ListBox2.List(Counter - 1) & vbCrLf
serverlist(Counter) = UserForm2.ListBox2.List(Counter - 1)
Next
For Each s In serverlist
Debug.Print s
Next
End Sub

WebGuy
07-13-2006, 05:32 AM
Thank you both for your efforts ! I managed to make it work just before my coffe break :)
Thanks yet again !