?
Solved

VB.Net Winform - TextBox Validation

Posted on 2010-08-31
6
Medium Priority
?
813 Views
Last Modified: 2012-05-10


VS 2005 / Vb.Net - Windows Application

I have almost 30 TextBox - For which i need  to handle Events like only Characters or Numbers ?

1) How to perform this

2) Is there any way  to write a Common Class and pass it on Event Handler of TextBox

Or Do i need to write some code on each and every textbox
0
Comment
Question by:chokka
[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
6 Comments
 
LVL 8

Accepted Solution

by:
Mikkk earned 668 total points
ID: 33574245

1 - Name every textbox different as if they has to be numeric values or text values, for example NTextBox1 will be numeric and TTextBox1 eill be text
2 - Assign the save procedure to each event of each control, and make this procedure process one or other thing by his name like the code attached.




    Private Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NTextBox1.TextChanged, NTextBox2.TextChanged, TTextBox1.TextChanged
        If sender.name.startswith("N") Then
            'is a numeric field
        Else
            'is a char field
        End If
    End Sub

Open in new window

0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 33574609
You're better option would be to create a custom control, derived from textbox, that implements this custom behaviour. But I guess it depends on how much time you have to devote to something like that.
0
 
LVL 28

Expert Comment

by:Ark
ID: 33574987
For numeric only you can set ES_NUMBER style
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 668 total points
ID: 33575180
0
 
LVL 8

Expert Comment

by:Mikkk
ID: 33576170
What I've written maybe is not the best way, but is the fastest way is you has the form drawn and the controls positioned.
If you only want to validate numbers, chars when an event occurs (in the example TextChanged but can be Validated) this is a fast solution.
0
 
LVL 18

Assisted Solution

by:John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou earned 664 total points
ID: 33590612
Select all the textboxes You want for raising the same event handler and find the event in properties window, doubleclick it or write a event handler name. This will add one event handler for all selected controls.
Hope it helps
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

771 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