I was trying to get this work, but couldn't find a way to work this out. I'm new to vb.net. In a text box, the user enters a number for example a 9 digit number. I want the user enter to enter a 9 digit number that is starting from 8. if the very first number of that set is not starting with 8 then give a error msg to the user to enter a number starting from 8.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If TextBox1.TextLength = 0 Then '// check if TextBox is empty.
If Not e.KeyChar = "8" Then '// if not "8".
e.Handled = True '// cancel the key pressed.
MsgBox("First character is not 8.", MsgBoxStyle.Critical) '// display message.