I need to be able to limit the text entered into a text box, I need to make it so that only whole numbers can be entered and not decimal places. I have already limited it to just Numbers but need help with this. I think checking a box to see if a fullstop is in it would be a good way but i dont know the command for searching a string.
Wilderness Bob
0
Newbie Poster
Recommended Answers
Jump to Postto limit text box set its property "MaxLength" to number you want to enter like to 3 or 6.
to check decimal put condition
somthing like this...
if textbox1.text=Asc(.) then
msgbox("Please dont enter Decimal Point, Thanks")
endif
Jump to PostPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim dt As Integer = Asc(Me.TextBox1.Text)
If TextBox1.Text = Chr(46) Then
MsgBox("You pressed dot")
End If
End Sub
this is one way you can check whether the dot is pressed or not
Jump to Posttry this following code, this code only allowed number entered on textbox :
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _ Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then e.Handled = True End If If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then e.Handled = …
All 12 Replies
Alekhan
0
Light Poster
Alekhan
0
Light Poster
Jx_Man
987
Nearly a Senior Poster
Featured Poster
suganzeni
0
Newbie Poster
SolTec
0
Junior Poster in Training
samichou6
0
Newbie Poster
SolTec
0
Junior Poster in Training
zyrole
0
Newbie Poster
§AE§
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Minimalist
96
Posting Pro
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.