PDA

View Full Version : deleting all entries in a combo



mattmac24
02-23-2004, 11:37 PM
ok at the moment my button looks like this:

Sub Command4_Click()
Dim line10
line10 = Combo1.ListIndex = -10

Dim line9
line9 = Combo1.ListIndex = -9

Dim line8
line8 = Combo1.ListIndex = -8

Dim line7
line7 = Combo1.ListIndex = -7

Dim line6
line6 = Combo1.ListIndex = -6

Dim line5
line5 = Combo1.ListIndex = -5

Dim line4
line4 = Combo1.ListIndex = -4

Dim line3
line3 = Combo1.ListIndex = -3

Dim line2
line2 = Combo1.ListIndex = -2

Dim Line1
Line1 = Combo1.ListIndex = -1

If line10 < 2 Then
Combo1.RemoveItem (Combo1.MultiSelect = 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If line9 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If line8 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If line7 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
End If

If line6 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If line5 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If line4 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If line3 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If line2 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

If Line1 < 2 Then
Combo1.RemoveItem (Combo1.ListCount - 1)
GoTo Start:
End If

it is really long and it dont even work...and the Dim things are wrong..im sure of it

and the start bit is ment to be there so just ignore that...

andone who knows how to delete all the items in 1 line please post....or tell me whats wrong with my bad one

thanks

matt

mattmac24
02-23-2004, 11:40 PM
also in the combo box are a list of IP's..can i Net send all at once?....but not using "*" as the address

i can net send one but not all at once.

thanks, matt

Brf
02-24-2004, 04:17 AM
What are you trying to accomplish?

Your "IF" statements will all always be true, because your variables will be assigned "true" (1 or -1) or false (0) so they are always < 2.

Also... isnt a listindex always positive?

mattmac24
02-24-2004, 12:40 PM
your proberly right..i have no idea about any of this...im just starting....i am trying to delete all the enteries in a combo. i have no idea what your talking about when you were on about true,0,1 and stuff. i just want it to see if the tenth entry is longer then 2 and then delete 10 lines...if not then i want it to see if the 9th entry is longer then two, then delete 9 lines...but im not sure how to select the 10th line...

Dim line10
line10 = Combo1.ListIndex = -10

and for some reason i expect that to select the 10th entry in the combo....what should it be instead?

Brf
02-24-2004, 01:09 PM
No.

Line10 = Combo1.ListIndex = -10

sets Line10 to (true) if Combo1.Listindex is -10 and sets it to (false) if it isnt.

If all you are trying to do is delete all the lines in a combo box... just use:

combo1.clear

<P ID="edit"><FONT class="small">Edited by Brf on 02/24/04 13:13.</FONT></P>

mattmac24
02-24-2004, 04:11 PM
ok thanks heaps,

so all i need is:

Sub Command4_Click()
Combo1.clear
End sub

and that clears all entries? thanks heaps. lol that aved me about 50 lines lol

thanks

mattmac24
02-24-2004, 04:15 PM
could somebody just give me a example(i learn best by example) of when youd use the true and false stuff?...not to do with my above stuff..just in general...or just explain what each of them does?


thanks matt