if textbox have numbers then ...
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions 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.
5 posts
Page 1 of 1
hi im making a program now im stuck
i wanna make a simple code to check if
textbox1.text has numbers and have
no letters then it will msgbox else it will
do nothing
i will make a fake code to make it easier
if textbox1.text have numbers and dont have letters or characters then
msgbox("yolo")
thnx :?
i wanna make a simple code to check if
textbox1.text has numbers and have
no letters then it will msgbox else it will
do nothing
i will make a fake code to make it easier
if textbox1.text have numbers and dont have letters or characters then
msgbox("yolo")
thnx :?
try this code:::
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim value As Integer
Dim text As String = TextBox1.Text
If Integer.TryParse(text, value) Then
MsgBox(value.ToString)
Else
MsgBox("the value is not an integer")
End If
End Sub
noypikami wrote:try this code:::thanks lol i didnt expect anyone to answer me this early, im going to school now when i come back i will tell you if it works
Code: Select allPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim value As Integer Dim text As String = TextBox1.Text If Integer.TryParse(text, value) Then MsgBox(value.ToString) Else MsgBox("the value is not an integer") End If End Sub
loove; loove; cooll;
Hi,
Try this
Function :
Try this
Function :
Code: Select all
Usage : Private Function IsInputNumeric(input As String) As Boolean
If String.IsNullOrWhiteSpace(input) Then Return False
If IsNumeric(input) Then Return True
Dim parts() As String = input.Split("/"c)
If parts.Length <> 2 Then Return False
Return IsNumeric(parts(0)) AndAlso IsNumeric(parts(1))
End Function
Code: Select all
Source : http://stackoverflow.com/a/15423718/2443148If IsInputNumeric(TextBox1.Text) Then
'handle numeric input
Else
'handle not a number
End If
Find my programs on Softpedia
#Shim, don't forget to mention this code will also allow slashes ("/") ;)
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023