Palehorse
09-17-2004, 04:39 PM
Programmers,
I have a problem, I have a ini that has a bunch of numbers listed in it like so:
123
456
789
At form load, this data is populated in a listbox. You can select multiple numbers at a time in the listbox. While these numbers are selected, I click on my "Remove" button, and it should remove the selected items off the listbox. The ini file is left alone. This is my progress, however it is flawed:
Private Sub cmdRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemove.Click
Try
Dim aryListSelected As String
Dim arySelected() As String
Dim intNames As Integer
If lstNames.SelectedItems.Count > 0 Then
For Each strSeleted As String In lstNames.SelectedItems
If Len(aryListSelected) > 0 Then
aryListSelected &= mySeperator
End If
aryListSelected &= lstNames.SelectedIndex.ToString
Next strSeleted
arySelected = Split(aryListSelected, mySeperator)
End If
For intLoop As Integer = 1 To intNames
lstNames.Items.RemoveAt(Val(arySelected(intLoop - 1)))
Next intLoop
Catch ex As Exception
Call MessageBox.Show(ex.Message, Windows.Forms.Application.ProductName, MessageBoxButtons.OK)
End Try
End Sub
I have a problem, I have a ini that has a bunch of numbers listed in it like so:
123
456
789
At form load, this data is populated in a listbox. You can select multiple numbers at a time in the listbox. While these numbers are selected, I click on my "Remove" button, and it should remove the selected items off the listbox. The ini file is left alone. This is my progress, however it is flawed:
Private Sub cmdRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemove.Click
Try
Dim aryListSelected As String
Dim arySelected() As String
Dim intNames As Integer
If lstNames.SelectedItems.Count > 0 Then
For Each strSeleted As String In lstNames.SelectedItems
If Len(aryListSelected) > 0 Then
aryListSelected &= mySeperator
End If
aryListSelected &= lstNames.SelectedIndex.ToString
Next strSeleted
arySelected = Split(aryListSelected, mySeperator)
End If
For intLoop As Integer = 1 To intNames
lstNames.Items.RemoveAt(Val(arySelected(intLoop - 1)))
Next intLoop
Catch ex As Exception
Call MessageBox.Show(ex.Message, Windows.Forms.Application.ProductName, MessageBoxButtons.OK)
End Try
End Sub