G
Guest
In VB.NET Windows Form, how do I set my text box to only allow numbers?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Mike L said:In VB.NET Windows Form, how do I set my text box to only allow numbers?
or buy Farpoint's Inputpro - no connection other than as a customerHerfried said:Place an ErrorProvider component on the form and add this code:
\\\
Imports System.ComponentModel
..
..
..
Private Sub TextBox1_Validating( _
ByVal sender As Object, _
ByVal e As CancelEventArgs _
) Handles TextBox1.Validating
Dim SourceControl As TextBox = DirectCast(sender, TextBox)
Dim ErrorText As String
Try
Dim i As Integer = Integer.Parse(SourceControl.Text)
Catch
ErrorText = "Value must be an integer."
Finally
Me.ErrorProvider1.SetError( _
SourceControl, _
ErrorText _
)
End Try
End Sub
///
Mike L said:In VB.NET Windows Form, how do I set my text box to only allow numbers?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.