Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Can Anyone Help Me?

Hi... uh, at the moment in college, we are doing an assignment on Visual Basic 6.. and the project has numerous arrays... everything is fine and dandy except for the button that is supposed to delete an element from the array. The names of the elements don't even appear in the combo box, and I can't figure out why.. also my tutor is adamant that I figure it out for myself.. but I can't.. so I wonder if you could look at this code, and tell me what I need to add?

Thanks.

--

Private Sub cboDeletePlayer_Click()
Dim Start As Integer
Dim Found As Boolean
Dim Pos As Integer

For Index = 0 To Pos Step 1

If (StrComp(PlayersName(Index), vbTextCompare) = 0) Then
Pos = PlayersName(Index)
End If

Next Index

For Start = Pos To NumberOfPlayers
PlayersName(Start) = PlayersName(Start + 1)
Scores(Start) = Scores(Start + 1)
IDNumber(Start) = IDNumber(Start + 1)
Next Start

For Index = 1 To NumberOfPlayers
cboDeletePlayer.Clear
cboChallenger.Clear
cboHigherPlayer.Clear
NumberOfPlayers = NumberOfPlayers - 1
Next Index

For Index = 1 To NumberOfPlayers
cboDeletePlayer.AddItem PlayersName(Index)
cboHigherPlayer.AddItem PlayersName(Index)
cboChallenger.AddItem PlayersName(Index)
Next Index

lblName(Index).Caption = PlayersName(Index)
lblID(Index).Caption = IDNumber(Index)
lblScores(Index).Caption = Scores(Index)

End Sub
[1600 byte] By [*Amata*] at [2007-11-11 7:20:18]
# 1 Re: Can Anyone Help Me?
hi

i am new to vb but have played with arrays.

in my progs to remove an item from an array/listbox/combobox you would need to do:
COMBOBOX.removeitem INDEX
caps are the variables/names you have set to those attributes.
couldn't see removeitem anywhere in your code so think this is where you need to start looking. sorry can't be more help but i certainly know less than anyone else on here as haven't learnt vb - only fidled with it.
twazok at 2007-11-11 17:27:10 >