?
Solved

Mask Text Control

Posted on 2009-04-09
4
Medium Priority
?
332 Views
Last Modified: 2012-05-06
Hi,

I want a mask input control with the following behaviour...

The user can only enter a floating point number with either two, one, zero signifiacnt digits and up to six digits after the decimal point (this number represents a rate) the user should also be able to enter a minus sign (if required) to represent a negative rate....

How do I acheive this...? Is a "MaskedTextbox" the best way to achieve this..?

Thanks Ian
0
Comment
Question by:ISC
[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
  • 3
4 Comments
 
LVL 15

Expert Comment

by:spprivate
ID: 24108692
MaskedTextBox is for passwords or confidential data.
For you you need a regular expression
0
 
LVL 15

Expert Comment

by:spprivate
ID: 24108773
I am sorry,my comment about masked text box was wrong.That is a formatter but for you we need to look into regex
0
 
LVL 15

Accepted Solution

by:
spprivate earned 2000 total points
ID: 24109216
I was in VB 6.0 mode.Here we go
    Public Function IsValid(ByVal Str As String) As Boolean
     
        Dim pattern As String = "^(-)?\d+(\.\d{1,6})?$"
        Dim check As New System.Text.RegularExpressions.Regex(pattern, RegexOptions.IgnorePatternWhitespace)
        Dim valid As Boolean = False
        valid = check.IsMatch(Str)
        Return valid
    End Function
 
    Private Sub TextBox1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Leave
        If Not IsValid(TextBox1.Text) Then
            MessageBox.Show("Wrong")
            TextBox1.Focus()
            TextBox1.Text = ""
 
        End If
 
    End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:ISC
ID: 31568604
Thanks for this I learnt something new...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 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