I've newly joined this forum since I want to enhance my knowledge in Programming specially in Visual Basic.
So for the important part, right now I'm planning on creating a word detector somehow and there are specific rules I was to set in the textbox in relation with the button.
Let's say I wanna set an IF Statement for the text to have 32 characters and letters "abcdefg" and numbers "12345" so that it'll execute a message box when I press the button.
Here's a code example of what I'm saying
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text.Length.Equals(32) Then
MessageBox.Show("You word has 32 Characters")
As you can see, I've set a rule that a message box will pop up if the word has 32 characters.
But I need to set another rule at the same time in which the word will have only letters "abcdefg" and numbers "12345"
I suggest to trap it when user input the characters.
So, users can only input the specific characters.
Example : (This text box only accept numbers input only)
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
e.Handled = True
If Asc(e.KeyChar) = 8 Then
e.Handled = False