Help
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Hello ipol,
Click the textbox on your form, and to the properties, and find something called MaxLenght put it to 25, as shown on the image below. Then if you want the user to not be able to write alphabetical characters, use this:
Click the textbox on your form, and to the properties, and find something called MaxLenght put it to 25, as shown on the image below. Then if you want the user to not be able to write alphabetical characters, use this:
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "1111122222333334444455555" Then
MsgBox("valid key!")
Else
MsgBox("invalid key!")
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar <> ChrW(Keys.Back) Then
If (e.KeyChar.ToString >= "0" And e.KeyChar.ToString <= "9") Then
Else
e.Handled = True
End If
End If
End Sub
You do not have the required permissions to view the files attached to this post.
It is not clear how you would limit the number range with that code.
You can use this:
You can use this:
Code: Select all
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim number As Integer
Try
number = Integer.Parse(TextBox1.Text)
Catch ex As Exception
TextBox1.Text = ""
Return
End Try
If number < 1 Or number > 25 Then
MsgBox("Number is not allowed")
TextBox1.Text = ""
End If
End Sub
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023