Link to home
Create AccountLog in
Avatar of Ahmadal_najjar2003
Ahmadal_najjar2003Flag for Kuwait

asked on

How Also to let text accept point .

I have a text box , I want it to accept both numbers and point just to enter amount like this 2.75 .

  Private Sub thiscontrol_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles thiscontrol.KeyPress
        If Char.IsNumber(e.KeyChar) = False And Char.IsControl(e.KeyChar) = False Then
            e.Handled = True
        End If
    End Sub

What also I have to add. ?
Avatar of rachitkohli
rachitkohli
Flag of India image

Or (e.KeyChar = "." And Split(thiscontrol.Text, ".").Length <= 1)

add this OR condition also, this will make sure only once "." is entered
ASKER CERTIFIED SOLUTION
Avatar of rachitkohli
rachitkohli
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Ahmadal_najjar2003

ASKER

Thanks Alot