Application turminates after loop!

jorge

Junior Contributor
Joined
Jul 13, 2003
Messages
239
Location
Belgium
Here is the code, and my apps crashes after it is done!
Visual Basic:
        Dim sServerFav_new As String
        Dim serverfav_rm As String
        serverfav_rm = lbfavserver.SelectedItem
        Dim i
        For i = 0 To lbfavserver.Items.Count
            lbfavserver.SelectedIndex = i
            If lbfavserver.SelectedItem <> serverfav_rm Then
                sServerFav_new = sServerFav_new + lbfavserver.SelectedItem + "|"
            End If
        Next i
        MsgBox(sServerFav_new)
 
Doesn't seem like it should -- is there anything after that sub? In what context is that code used?
 
i'm added a lisbox with keep ip addresses, and a add and remove button and this code is for the remove button so it remove the selectet item and recoposes the string to save in the regestry,
and there is nothing after this acepte end sub
here is the code fot both buttons:
Visual Basic:
    Private Sub cmdaddserver_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdaddserver.Click
        Dim sServerFav_new As String
        Dim serverfav_Add As String
        serverfav_Add = InputBox("Ip Adress", "Add Server")
        sServerFav_new = sServerFav + serverfav_Add + "|"
        SaveSetting("ApacheMon", "Settings", "sServerFav", sServerFav_new)
        sServerFav = sServerFav_new
        serverfav_reload()
    End Sub

    Private Sub cmdrmserver_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrmserver.Click
        Dim sServerFav_new As String
        Dim serverfav_rm As String
        serverfav_rm = lbfavserver.SelectedItem
        Dim i
        For i = 0 To lbfavserver.Items.Count
            lbfavserver.SelectedIndex = i
            If lbfavserver.SelectedItem <> serverfav_rm Then
                sServerFav_new = sServerFav_new + lbfavserver.SelectedItem + "|"
            End If
        Next i
        MsgBox(sServerFav_new)
    End Sub
 
Ah yes, that will do it. For some reason I was under the impression it was just closing without an error message (I guess because he said the application "terminates" -- I've been subclassing VB6 too much I guess :p). :o
 
Ok it still seem a bit buggy, when there are 2x the same item it still craches, and frmmain.lbfavserver.items.clear() doen't work
 
Back
Top