Thank you both for replying to my questions. Because my lack of knowledge I ended up writing the file with each line followed by comma and opening it again to delete the last 3 characters (carriage return and comma) which worked alright.But i would like try your solutions also.
The solution using isFirstItem works only for first item very well and I'll keep that in mind next time.
Now, i'm intrigued about reading the selected option into a indexed array for future knowledge. Being given this select element
<select size="13" name="AvailableOptions" style="width:110px" multiple="multiple" >
<option value="192.168.0.1">PC01</option>
<option value="192.168.0.3">PC02</option>
<option value="192.168.0.2">PC03</option>
<option value="192.168.0.4">PC04</option>
<option value="192.168.0.5">PC05</option>
<option value="192.168.0.6">PC06</option>
<option value="192.168.0.7">PC07</option>
<option value="192.168.0.8">PC08</option>
<option value="192.168.0.9">PC09</option>
<option value="192.168.0.10">PC10</option>
<option value="192.168.0.11">PC11</option>
<option value="192.168.0.12">PC12</option>
<option value="192.168.0.13">PC13</option>
<option value="192.168.0.14">PC14</option>
</select>
I've managed to put the selected options into an array:
Dim aSelected : aSelected = Array()
Dim nIdx
For nIdx = 0 to AvailableOptions.Options.Length - 1
If AvailableOptions.Options(nIdx).Selected Then
ReDim Preserve aSelected( UBound( aSelected ) + 1 )
aSelected( UBound( aSelected ) ) = AvailableOptions.Options(nIdx).Value
End If
Next
And this is where I think it could be done better:
Dim strComputer Dim aIdx : aIdx = 0 For Each strComputer In aSelected If aIdx=UBound(aSelected) Then
MsgBox strComputer
Else
MsgBox strComputer & ","
End If
aIdx=aIdx+1
Next
For future knowledge also i would like to know a couple of things:
1. how to retrieve the number of items in an array [ for the time being i consider that to be ubound(a)+1]? is there any myarray.count method?
2. how to create an indexed array? is the array i've created considered an indexed array ?
Thanks!
<message edited by cippall on Sunday, January 08, 2012 10:44 AM>