I have been trying to figure out what I have done with this program that when I run debug and put in an invalid number it outputs invalid number like is is suppose to. BUT when I put in A102, C220, C510, F251, and F503 it makes my computer freeze up every time. Here is my code. I'm sure it is an easy fix but I can't find it. I am a new student to programming. Any help is greatly appreciated. Thank you
Public Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
' searches an array for an employee ID and then
' displays either the salary from another
' array or a message
' declare parallel arrays
Dim strIds() As String =
{"A102", "C220", "C510", "F251", "F503"}
Dim intSalaries() As Integer =
{25000, 50000, 43000, 23000, 32000}
Dim strSearchFor As String
Dim intSub As Integer
Dim strFound As String
' assign the ID to a variable
strSearchFor = txtId.Text.Trim.ToUpper
' search the strIds array for the ID
' continue searching until the ID is found
' or the end of the array is reached
intSub = 0
strFound = "N"
Do Until strFound = "Y" OrElse intSub = strIds.Length
If strIds(intSub) = strSearchFor Then
strFound = "y"
Else
intSub = intSub + 1
End If
Loop
' determine whether the ID was found
If strFound = "Y" Then
lblSalary.Text =
intSalaries(intSub).ToString("CO")
Else
lblSalary.Text = "Invalid ID"
End If
End Sub
Private Sub txtId_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtId.TextChanged
lblSalary.Text = String.Empty
End Sub
End Class
Public Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
' searches an array for an employee ID and then
' displays either the salary from another
' array or a message
' declare parallel arrays
Dim strIds() As String =
{"A102", "C220", "C510", "F251", "F503"}
Dim intSalaries() As Integer =
{25000, 50000, 43000, 23000, 32000}
Dim strSearchFor As String
Dim intSub As Integer
Dim strFound As String
' assign the ID to a variable
strSearchFor = txtId.Text.Trim.ToUpper
' search the strIds array for the ID
' continue searching until the ID is found
' or the end of the array is reached
intSub = 0
strFound = "N"
Do Until strFound = "Y" OrElse intSub = strIds.Length
If strIds(intSub) = strSearchFor Then
strFound = "y"
Else
intSub = intSub + 1
End If
Loop
' determine whether the ID was found
If strFound = "Y" Then
lblSalary.Text =
intSalaries(intSub).ToString("CO")
Else
lblSalary.Text = "Invalid ID"
End If
End Sub
Private Sub txtId_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtId.TextChanged
lblSalary.Text = String.Empty
End Sub
End Class