473,397 Members | 2,028 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,397 software developers and data experts.

Maximum Character Length

toxicpaint
Hi,

I'm sure there is a really easy way to do this and I'm just being silly, but is there a way that I can get a text box to stop people typing when it hits its maximum character length.

I've created an page with a notes section you see and this writes to an Access database. the problem is that Access can only take 255 characters as a maximum. I have set a MaxChar value in the properties of the text box but you can type in as much stuff as you like.

Can anyone help?

Thanks a lot,

Tom
Feb 27 '07 #1
5 3154
vijaydiwakar
579 512MB
Hi,

I'm sure there is a really easy way to do this and I'm just being silly, but is there a way that I can get a text box to stop people typing when it hits its maximum character length.

I've created an page with a notes section you see and this writes to an Access database. the problem is that Access can only take 255 characters as a maximum. I have set a MaxChar value in the properties of the text box but you can type in as much stuff as you like.

Can anyone help?

Thanks a lot,

Tom
just try this code
Expand|Select|Wrap|Line Numbers
  1.  
  2. if txt.text.len >255 then ' donot trim it
  3. 'suppress key code here
  4. end if
  5.  
use this code in keypress event where u get option to supress the key
try it
Feb 27 '07 #2
Thanks a lot for that. I had to change ..Text.len into Text.Length as visual basic didn't recognise it but the strtucte seems to be okay.

I can't seem to supress keys though. Do you know how I can suppress all keys except backspace and tab?

Thanks!
Feb 27 '07 #3
BTW,

I'm using ASPX and VB in Visual Studio 2005 with .NET 2.0
Feb 27 '07 #4
vijaydiwakar
579 512MB
Thanks a lot for that. I had to change ..Text.len into Text.Length as visual basic didn't recognise it but the strtucte seems to be okay.

I can't seem to supress keys though. Do you know how I can suppress all keys except backspace and tab?

Thanks!
dear u can't tress tab in .net but u can supress backspace or any char as
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  3. If e.KeyChar = vbBack Then e.KeyChar = vbNullChar
  4. end sub
  5.  
try it
Feb 27 '07 #5
I get the following error:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'KeyChar' is not a member of 'System.EventArgs'.

Source Error:



Line 68: Private Sub Notes_KeyPress(ByVal sender As Object, ByVal e As System.EventArgs) Handles Notes.TextChanged
Line 69: If Notes.Text.Length > 255 Then
Line 70: If e.KeyChar = vbBack Then e.KeyChar = vbNullChar
Line 71: End If
Line 72: End Sub


Source File: C:\Inetpub\wwwroot\software\Default.aspx.vb Line: 70
Feb 27 '07 #6

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

Similar topics

1
by: Bert Sierra | last post by:
Does anyone know if there's an upper limit to the length of the query string supplied to the mysql_query() function? It appears that strings themselves can go well beyond 65,536 characters: the...
4
by: Lobang Trader | last post by:
Hi all, I am trying to create a username and a password class. I would like to know what are the RECOMMENDED minimum and maximum length for both fields? These fields will be something like...
8
by: Hal Vaughan | last post by:
Is there a maximum length for Javascript program lines? What about strings? Is there a limit on string length? I found some references that said the maximum string length was 256 characters,...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
12
by: dixie | last post by:
Is there a maximum length in VBA of a line containing stuff like the following: If password = "1234" or password = "1235" or password = ............... Then It seems to me that at some stage, I...
15
by: Lauren Wilson | last post by:
Access 2K dim MyStr as string What is the maximum amount of text or bytes that this variable can store? Does anyone know?
3
by: hug | last post by:
The valid character set for the ID= attribute of html tags is listed here (http://www.htmlhelp.com/reference/html40/attrs.html) but I am having difficulty finding the maximum allowable length of...
1
by: hn.ft.pris | last post by:
"Forward maximum match" mean that there is a dictionary contains thousands of items which are single words. For example, "kid", "nice", "best"... And here get a string "kidnicebs", the forward...
11
by: =?Utf-8?B?VmxhZCBIcnlib2s=?= | last post by:
Using IIS7, Vista x64, ASP.NET 2.0. I am getting HTTP 400 "Bad Request" for the following URL:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.