Quantcast
Channel: Allow only a decimal point after an input of three digits in a textbox in VB.NET? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Allow only a decimal point after an input of three digits in a textbox in VB.NET?

$
0
0

How do I allow only a decimal point after an input of three digits in a textbox in VB.NET?

Let's say I inputed "123" after that I can only put a decimal else it wont allow any other input. So the result would be "123."

    Dim KeyAscii As Integer    KeyAscii = Asc(myE.KeyChar)    Select Case KeyAscii        Case Asc("0") To Asc("9"), Asc(ControlChars.Back)            myE.Handled = False        Case Asc(".")            If InStr(myTextbox.Text, ".") = 0 Then                myE.Handled = False            Else : myE.Handled = True            End If        Case myE.KeyChar = Chr(127)            myE.Handled = False        Case Else            myE.Handled = True    End Select

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>