I have been looking over things, and since google to me is not helping but giving me a headach, I wanted to see if someone here can help.
I am trying to get this application to search two list box's but when i run the application it freezes up when I search from a second List box. And it still selects from the first boxx as well as the second one. I am getting frustrated with this project, yes it is for a class. I am learning this all over. Any help will be appreciated.
Here is the code.
I am trying to get this application to search two list box's but when i run the application it freezes up when I search from a second List box. And it still selects from the first boxx as well as the second one. I am getting frustrated with this project, yes it is for a class. I am learning this all over. Any help will be appreciated.
Here is the code.
VB.NET:
Option Explicit On
Option Strict On
Option Infer Off
Public Class ShipWithUs
Private Sub zipTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles zipTextBox.Enter
Select Case zipListBox1.SelectedIndex
Case 0
shippingText.Text = "$15"
Case 1
shippingText.Text = "$15"
Case 2
shippingText.Text = "$15"
Case 3
shippingText.Text = "$15"
Case 4
shippingText.Text = "$15"
Case 5
shippingText.Text = "$15"
Case 6
shippingText.Text = "$15"
Case 7
shippingText.Text = "$15"
End Select
Select Case zipListBox2.SelectedIndex
Case 0
shippingText.Text = "$20"
Case 1
shippingText.Text = "$20"
Case 2
shippingText.Text = "$20"
Case 3
shippingText.Text = "$20"
Case 4
shippingText.Text = "$20"
End Select
End Sub
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' fills the list box 1 with values
zipListBox1.Items.Add("60611")
zipListBox1.Items.Add("60234")
zipListBox1.Items.Add("56789")
zipListBox1.Items.Add("23467")
zipListBox1.Items.Add("60543")
zipListBox1.Items.Add("60561")
zipListBox1.Items.Add("55905")
zipListBox1.Items.Add("89567")
zipListBox2.Items.Add("50978")
zipListBox2.Items.Add("78432")
zipListBox2.Items.Add("98432")
zipListBox2.Items.Add("97654")
zipListBox2.Items.Add("20245")
End Sub
Private Sub displayshippingButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles displayshippingButton.Click
'determines whether a list box contains a specific ID
Dim isFound As Boolean
Dim index As Integer
Dim numberofitems As Integer
Dim id As String = String.Empty
'assign id and number of list box items to variables
id = zipTextBox.Text.ToUpper
numberofitems = zipListBox1.Items.Count
numberofitems = zipListBox2.Items.Count
'search the list box, stopping either after the
'last item or when the item is found
Do While index < numberofitems AndAlso isfound = False
If id = zipListBox1.Items(index).ToString.ToUpper Then
isFound = True
Else
If id = zipListBox2.Items(index).ToString.ToUpper Then
isFound = True
End If
End If
index = index + 0
Loop
If isFound = True Then
zipListBox1.SelectedIndex = index
zipListBox2.SelectedIndex = index
Else
zipListBox1.SelectedIndex = -1
MessageBox.Show("Not Found", "Product Finder", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
zipTextBox.SelectAll()
Select Case zipListBox1.SelectedIndex
Case 0
shippingText.Text = "$15"
Case 1
shippingText.Text = "$15"
Case 2
shippingText.Text = "$15"
Case 3
shippingText.Text = "$15"
Case 4
shippingText.Text = "$15"
Case 5
shippingText.Text = "$15"
Case 6
shippingText.Text = "$15"
Case 7
shippingText.Text = "$15"
End Select
Select Case zipListBox2.SelectedIndex
Case 0
shippingText.Text = "$20"
Case 1
shippingText.Text = "$20"
Case 2
shippingText.Text = "$20"
Case 3
shippingText.Text = "$20"
Case 4
shippingText.Text = "$20"
End Select
Me.zipTextBox.Focus()
End Sub
End Class
Last edited by a moderator: