Solved

How Also to let text accept point .

Posted on 2008-06-17
3
173 Views
Last Modified: 2010-04-23
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. ?
0
Comment
Question by:Ahmadal_najjar2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Expert Comment

by:rachitkohli
ID: 21801227
Or (e.KeyChar = "." And Split(thiscontrol.Text, ".").Length <= 1)

add this OR condition also, this will make sure only once "." is entered
0
 
LVL 14

Accepted Solution

by:
rachitkohli earned 500 total points
ID: 21801234
Private Sub thiscontrol_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles thiscontrol.KeyPress
If Char.IsNumber(e.KeyChar) = True Or (e.KeyChar= "." And Split(thiscontrol.Text, ".").Length <= 1) Then
      e.Handled = True
        End If
    End Sub

this will be a complete event
0
 

Author Closing Comment

by:Ahmadal_najjar2003
ID: 31467898
Thanks Alot
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question