I have made a product key system that has a textbox and when I hit activate it reads a txt file with active product keys and it checks to make sure the textbox text is the same as one of the active codes in a text file. However, if I enter an invalid code, it freezes to death! maybe a bad code? Here is my code:
Dim code As String
code = TextBox1.Text
Try
Dim sr As IO.StreamReader = New IO.StreamReader("C:\Users\Chris\test.txt")
Dim line As String
Do
line = sr.ReadLine
Loop Until line = code
sr.Close()
my.settings.registered=True
MsgBox("Your code is valid")
Catch ex As Exception
MsgBox("You have entered an invalid code, please try again", MsgBoxStyle.Critical)
End Try