Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

May i ask how to make textbox only allow (-,.(dot)and number)

$
0
0

I write code about textbox allow numbers (-) and (.) dot
However, the (-) aspect is unavailable. can help me take a look. Thanks.
Below is my code

If sg1.Text = "" Then
            'sg1.Focus()
            'sg1.SelectAll()
        Else
            Try
                S1 = CDbl(CStr(sg1.Text))
            Catch ex As Exception
                'MsgBox("Pls fill correct number")
                sg1.Text = ""
            End Try

        End If

 If Not (Char.IsDigit(e.KeyChar) Or e.KeyChar = "." Or e.KeyChar = "-") And Not Char.IsControl(e.KeyChar) Then
            e.Handled = True
        End If



Viewing all articles
Browse latest Browse all 2535

Trending Articles



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