469,284 Members | 2,508 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,284 developers. It's quick & easy.

Textbox Maxlength mystery

I have set the MaxLength property of a textbox in a form
to 5 at design time. When I change the MaxLength back to 0
during run-time under some condition (for example, after clicking
a command button), I can still only enter at most 5 characters
into the textbox. So how can I reset the textbox to allow
unlimit text to be entered?
Jul 17 '05 #1
9 11245
Bo
Well, it worked fine for me. Why not post your source code, so we can see
what the problem is.

Oh, by the way, when you click the command button, are you creating an all
new instance of the form ? If you are, it will begin life using its design
time setting ( 5 bytes).

g'luck
"Lovely Dola" <do**@webinhk.com> wrote in message
news:ff*************************@posting.google.co m...
I have set the MaxLength property of a textbox in a form
to 5 at design time. When I change the MaxLength back to 0
during run-time under some condition (for example, after clicking
a command button), I can still only enter at most 5 characters
into the textbox. So how can I reset the textbox to allow
unlimit text to be entered?

Jul 17 '05 #2
Below is my source code for the Visual Basic form.
Well, when I run the program, I click the button and enter 5 for example.
Now I am limited to enter 5 characters into the textbox.
When I click the button and enter a value to 0, the Maxlength
property of the textbox is reset but I can still enter only 5 characters only.
Can anyone help me to solve this problem?
How can I reset the textbox so that I can enter unlimited text again?
-=-=-=-= SOURCE CODE =-=-=-=-=-

VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1725
ClientLeft = 60
ClientTop = 345
ClientWidth = 4140
LinkTopic = "Form1"
ScaleHeight = 1725
ScaleWidth = 4140
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 270
TabIndex = 1
Top = 975
Width = 1230
End
Begin VB.TextBox Text1
Height = 495
Left = 210
TabIndex = 0
Text = "Text1"
Top = 240
Width = 3510
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Dim s$

s = InputBox$("Enter Maxlength")
If IsNumeric(s) Then
Text1.MaxLength = CLng(s)
End If
End Sub
Jul 17 '05 #3
On 21 Oct 2003 03:14:11 -0700, do**@webinhk.com (Lovely Dola) wrote:
Below is my source code for the Visual Basic form.
Well, when I run the program, I click the button and enter 5 for example.
Now I am limited to enter 5 characters into the textbox.
When I click the button and enter a value to 0, the Maxlength
property of the textbox is reset but I can still enter only 5 characters only.
Can anyone help me to solve this problem?
How can I reset the textbox so that I can enter unlimited text again?


Funny that - I can enter almost any number

- are you sure that the code you posted behaves like that ?
Jul 17 '05 #4
er*****@nowhere.com (J French) wrote in message news:<3f***************@news.btclick.com>...
On 21 Oct 2003 03:14:11 -0700, do**@webinhk.com (Lovely Dola) wrote:
Below is my source code for the Visual Basic form.
Well, when I run the program, I click the button and enter 5 for example.
Now I am limited to enter 5 characters into the textbox.
When I click the button and enter a value to 0, the Maxlength
property of the textbox is reset but I can still enter only 5 characters only.
Can anyone help me to solve this problem?
How can I reset the textbox so that I can enter unlimited text again?


Funny that - I can enter almost any number

- are you sure that the code you posted behaves like that ?

Yes, I am sure it is exactly the same.
Have you tried to change MaxLength to 5 and then to 0
during the execution of the program?
Jul 17 '05 #5
On 21 Oct 2003 21:17:41 -0700, do**@webinhk.com (Lovely Dola) wrote:

<snip>
- are you sure that the code you posted behaves like that ?

Yes, I am sure it is exactly the same.
Have you tried to change MaxLength to 5 and then to 0
during the execution of the program?


Yes, it works fine

My guess is that you are actually entering something that is not
numeric

I strongly suggest that you avoid the use of IsNumeric() it has a
number of surprizing quirks
Jul 17 '05 #6
This is my another form that has the same problem.
This time the MaxLength of the textbox is set to 5 at design time.
When I run the program, I can only enter at most 5 characters which
is fine. When I click the command button, the MaxLength of the textbox
should have reset to zero. But after that I can still enter 5 characters
only. So can anyone please help me to clarify this?
Thanks a lot!

-=-=-=-=-= FORM SOURCE -=-=-=-=-=
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "&Reset"
Height = 495
Left = 1740
TabIndex = 1
Top = 1350
Width = 1215
End
Begin VB.TextBox Text1
Height = 510
Left = 195
MaxLength = 5
TabIndex = 0
Text = "Text1"
Top = 345
Width = 4365
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Text1.MaxLength = 0 ' <-- numeric zero
End Sub
Jul 17 '05 #7
On 22 Oct 2003 23:48:48 -0700, do**@webinhk.com (Lovely Dola) wrote:
This is my another form that has the same problem.
This time the MaxLength of the textbox is set to 5 at design time.
When I run the program, I can only enter at most 5 characters which
is fine. When I click the command button, the MaxLength of the textbox
should have reset to zero. But after that I can still enter 5 characters
only. So can anyone please help me to clarify this?
Thanks a lot!

-=-=-=-=-= FORM SOURCE -=-=-=-=-=
VERSION 5.00


I've saved the code as Form1.Frm, added it to a project, and it works
just fine

What version of VB are you using ?
It looks like VB5 which is what I use
Jul 17 '05 #8
It sounds really strange for me...
I am using Visual Basic 6.0 Enterprise Edition.
May be I have to give up working on this problem...

er*****@nowhere.com (J French) wrote in message news:<3f**************@news.btclick.com>...
On 22 Oct 2003 23:48:48 -0700, do**@webinhk.com (Lovely Dola) wrote:
This is my another form that has the same problem.
This time the MaxLength of the textbox is set to 5 at design time.
When I run the program, I can only enter at most 5 characters which
is fine. When I click the command button, the MaxLength of the textbox
should have reset to zero. But after that I can still enter 5 characters
only. So can anyone please help me to clarify this?
Thanks a lot!

-=-=-=-=-= FORM SOURCE -=-=-=-=-=
VERSION 5.00


I've saved the code as Form1.Frm, added it to a project, and it works
just fine

What version of VB are you using ?
It looks like VB5 which is what I use

Jul 17 '05 #9
On 24 Oct 2003 06:25:13 -0700, do**@webinhk.com (Lovely Dola) wrote:
It sounds really strange for me...
I am using Visual Basic 6.0 Enterprise Edition.
May be I have to give up working on this problem...


This is such a simple thing
If it does not work, then there must be something wrong with your copy
of VB

The only thing that I can think is that it is some 'early' problem
that was fixed by a service pack

The fact that nobody has popped up to say that suggests that it is not
the case.
Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Rodrigo DeJuana | last post: by
14 posts views Thread by Adam Clauss | last post: by
1 post views Thread by mg | last post: by
4 posts views Thread by hardcoded | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.