473,388 Members | 1,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to check the max length

chandru8
145 100+
Hi experts
In my project ill having many textboxes , for that i have to check the maxlength for exch textbox , the length should be equal to maxlength mentioned

how can we check this in general

i have written code in lost focus for each text box is there any better idea

and this code is possible

If txtAccountno.MaxLength = True Then
'its not working
Else

MsgBox ""

End If
thanks
Nov 28 '07 #1
6 4136
Killer42
8,435 Expert 8TB
You could do a loop through the Me.Controls collection, check for type of textbox (or check the name) and then test the length against MaxLength.

(Note, this applies to VB6. I don't know how you access the controls collection in later versions.)
Nov 28 '07 #2
chandru8
145 100+
thanks killer
is it possible to assign the tabindex for select text box if some other category choosen mean for that text box the tab index should be set from the begining


thank you so much
Nov 28 '07 #3
Killer42
8,435 Expert 8TB
thanks killer
is it possible to assign the tabindex for select text box if some other category choosen mean for that text box the tab index should be set from the begining
I don't know. Try it, and see what happens.
Nov 28 '07 #4
MiziaQ
63
Here's an example of an if statement which checks the length of a credit card number.

If Len(txtCreditCard.Text) < 16 Then

MsgBox "The Credit Card Number should consist of 16 numeric characters", vbExclamation, "Note"

End If
Nov 28 '07 #5
Ali Rizwan
925 512MB
Use this code to restrict the textbox input size.
Expand|Select|Wrap|Line Numbers
  1.  
  2. if len(text1)>6 then
  3. msgbox "More than 6 characters are not allowed"
  4. text1.text=""
  5. text1.setfocus
  6. end if
no when ever the user input more than 6 digits or characters a msg box appers and text1 will empty and get focused

i think this will help you.

GOODLUCK
ALI
Nov 28 '07 #6
9815402440
180 100+
hi
set the MaxLength property of text box in Properties window at design time.
user wont be able to type more than MaxLength characters.

regards
manpreet singh dhillon hoshiarpur
Nov 28 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Randell D. | last post by:
Folks, I've heard of buffer overflows being used/abused by hackers and believe one method to reduce this from happening is to check the length of my form data before writing it to my MySQL...
1
by: Bjoern Jackschina | last post by:
Hello, until now I have not found the mistake that I made. My source code for checking how many checkboxes or radiobuttons are used: <script language="JavaScript"><!-- function pruefen(){return...
2
by: Edward | last post by:
The following html / javascript code produces a simple form with check boxes. There is also a checkbox that 'checks all' form checkboxes hotmail style: <html> <head> <title></title> </head>...
5
by: Steve Wylie | last post by:
I am constructing an HTML questionnaire and one of the questions requires people to rate some choices from 1 to 5, where 1 is their favourite and 5 is their least favourite: Car Bus Taxi cab...
3
by: wj | last post by:
Hi all, Im trying to, deal with a problem that drives me crazy! Im useing the following code to chech the fields of a form before really submitting them: ------- <script...
3
by: frizzle | last post by:
Hi there, I'm building a multi-language PHP/mySQL -site. I'm also building a CMS for the site. There are 5 languages. In the CMS fields for e.g. english bodytext are called (id=)...
5
by: Krechting | last post by:
Hi ALl, I have a code that checks if the documents in a hyperlink field are still where they should be. I use fileexist(). First I want to filter out all the hyperlink fields that are empty. I...
5
by: Shapper | last post by:
Hello, I am using this code line to check i a variable exists: If cookie Is Nothing Then .... How can I check if cookie is empty when cookie exists? Thanks, Miguel
14
by: Ørjan Langbakk | last post by:
I have a form where the user has the possibility to enclose his name. email, address and phonenumber. I want to be able to check if some of the fields are filled - at least one. This is so that...
7
by: yhlove | last post by:
Hi I declared an array as follows: dim a as integer() somewhere else in my program I have the following command: redim preserve a(size) I want to check the array length like that if...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.