HP3000-L Archives

April 2003, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Wirt Atmar <[log in to unmask]>
Reply To:
Date:
Wed, 9 Apr 2003 16:03:02 EDT
Content-Type:
text/plain
Parts/Attachments:
text/plain (59 lines)
Gehang writes:

>  Same thing happens. After clicking a button you can enter more
>  text then maxlength should allow. It must be a VB bug, unless
>  there is something with text alignment that I don't know about..

It only took me a second to create a form composed of one entry text box and
three command buttons to verify the behavior that you're reporting.
Technically, what you're reporting is a bug, but I'm willing to cut Bill
Gates a great deal of slack when it comes to VB. I have been constantly
amazed at the quality and robustness of VB.

Because of that amazement, I have found it profitable on a great number of
occasions to "think" like the software to find workarounds. Controls are
event-driven, object-oriented, structure-like subroutines in VB. In the case
of a textbox, a "maxlength" property value of 0 indicates that there is no
maxlength at all, thus the act of setting a maxlength = 0 must cause the
control to reset its internal state variables.

Doing exactly that in the buttons' program allows you to create the behavior
you want:

=======================================

Option Explicit

Private Sub Command1_Click()
  Text1.MaxLength = 0
  Text1.Alignment = vbLeftJustify
  Text1.MaxLength = 5
End Sub


Private Sub Command2_Click()
  Text1.MaxLength = 0
  Text1.Alignment = vbCenter
  Text1.MaxLength = 5
End Sub


Private Sub Command3_Click()
  Text1.MaxLength = 0
  Text1.Alignment = vbRightJustify
  Text1.MaxLength = 5
End Sub

=======================================

...although I only set my MaxLength's to 5, rather than your 28, simply so
that I didn't have to type as much in order to reach the limit specified.
While I realize that this solution isn't exactly obvious and is probably no
where documented in all of the thousands of pages written on VB, it is wholly
consistent with the philosophy of design that VB incorporates.

Wirt Atmar

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2