|
-
Jan 23rd, 2008, 01:04 PM
#1
Thread Starter
New Member
[2005] Removing SelectedItem from ListBox
Well im working on this school project and im stumped on this Do loop im trying to code. The project is constructing an airline like booking form where you have departing, arriving, and airline listboxes. My problem is getting the selection from the departing box not to appear in the arriving box, here is my code so far.
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim locationStreamReader As New StreamReader("f:\VB\Locations.txt")
Dim airlineStreamReader As New StreamReader("f:\VB\Airlines.txt")
Dim locationString As String
Dim airlineString As String
Do Until locationStreamReader.Peek = -1
locationString = locationStreamReader.ReadLine
departListBox.Items.Add(locationString)
arriveListBox.Items.Add(locationString)
Loop
locationStreamReader.Close()
Do Until airlineStreamReader.Peek = -1
airlineString = airlineStreamReader.ReadLine
airlineListBox.Items.Add(airlineString)
Loop
airlineStreamReader.Close()
Catch
MessageBox.Show("File doesn't exist.")
End Try
End Sub
Private Sub displayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles displayButton.Click
quoteLabel.Text = "You are departing from " & departListBox.SelectedItem & _
" you will be arriving at " & arriveListBox.SelectedItem & " and you will be flying on " & airlineListBox.SelectedItem
End Sub
Private Sub departListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles departListBox.SelectedIndexChanged
arriveListBox.Items.Clear()
Do Until departListBox.Items.Count = 0
If departListBox.SelectedItem = True Then
arriveListBox.SelectedItem.Remove()
End If
Loop
End Sub
Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Close()
End Sub
End Class
Any help or suggestions will be greatly appreciated!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|