Wrox Programmer Forums
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2004, 12:42 AM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validation

Hi:

i want to set validation in text boxes in VB.NET. For example, i have a text box that can take a maximum of 3 digits. before you insert a record by clicking on a button, it validates all text boxes. how do i do that?

code that i wrote:

If (Not IsNumeric(txtSubAreaNo.Text)) Then
            lblComment.Text = "Please enter a numeric SubArea Number"

this text box should only allow 3 digits maximum to be entered.

Thanks in advance
 
Old September 14th, 2004, 01:06 AM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for each ctl in me.controls
    if ctl.gettype="TextBox" ctl.MaxLenth=3
next

 
Old September 14th, 2004, 03:57 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 you try to use regular expressions, i think this is the beter way.
steps.
 1. frist drag the regular expression validatior,
 2. go to properties window and set the controle to validate to your text box
 3. write regular expression at validation expression in properties window

  for maximum of three digits the expression is: ^\d{1,3}$
any number that is 1 to 3 digits in length.eg:matches 1, 15, or 987.



 
Old September 14th, 2004, 07:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You can use a range validator. They are designed for that.

 
Old October 8th, 2004, 04:05 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Go to the following page for more information about the validator control creation

http://msdn.microsoft.com/library/de...asp?frame=true




It is not how much we do,
but how much love we put in the doing.

-Mother Theresa





Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Validation using Validation Framework kalyangvd Struts 1 January 2nd, 2008 06:53 AM
validation mikedeepak ASP.NET 2.0 Basics 0 May 28th, 2007 03:20 AM
Validation g_vamsi_krish ASP.NET 1.0 and 1.1 Professional 2 January 11th, 2006 06:46 AM
Validation koneruvijay ADO.NET 1 January 6th, 2004 09:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.