Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computer Certification > MCSD > very stupid question

Reply
Thread Tools

very stupid question

 
 
Jaime
Guest
Posts: n/a
 
      09-21-2003
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
TextBox1.MaxLength = 2
TextBox1.Text = "Hello"

End Sub
End Class

why when I run this does it display hello instead of he?
 
Reply With Quote
 
 
 
 
maria
Guest
Posts: n/a
 
      09-21-2003
Not stupid, but maybe a little lazy?
You can find answers to this kind of question by searching
msdn - as I just did ;o))

Check out these two pages

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/vbcon/html/vberrmaxlengthpropertybehaviorhaschanged.asp

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/vbcon/html/vbconcontrolpropertymethodeventchangesinvisua
lbasicnet.asp

Happy hunting

>-----Original Message-----
> Private Sub Button1_Click(ByVal sender As
>System.Object, ByVal e As System.EventArgs) Handles
>Button1.Click
> TextBox1.MaxLength = 2
> TextBox1.Text = "Hello"
>
> End Sub
>End Class
>
>why when I run this does it display hello instead of he?
>.
>

 
Reply With Quote
 
 
 
 
Jay Walters
Guest
Posts: n/a
 
      09-22-2003
I didn't look it up - but if you think about it, the
answer is pretty easy. (not meaning to insult).

We commonly use MaxLength to limit the input to a text
box right? -- So my guess would be that MaxLength only
affects input (internally on KeyDown). Hence writing any
code that sets the text would by-pass this check, which
is by design and not a bug.

Hope this helps.



>-----Original Message-----
> Private Sub Button1_Click(ByVal sender As
>System.Object, ByVal e As System.EventArgs) Handles
>Button1.Click
> TextBox1.MaxLength = 2
> TextBox1.Text = "Hello"
>
> End Sub
>End Class
>
>why when I run this does it display hello instead of he?
>.
>

 
Reply With Quote
 
Jaime
Guest
Posts: n/a
 
      09-22-2003
Yes that helps a whole lot, thank you so much.
>-----Original Message-----
>I didn't look it up - but if you think about it, the
>answer is pretty easy. (not meaning to insult).
>
>We commonly use MaxLength to limit the input to a text
>box right? -- So my guess would be that MaxLength only
>affects input (internally on KeyDown). Hence writing any
>code that sets the text would by-pass this check, which
>is by design and not a bug.
>
>Hope this helps.
>
>
>
>>-----Original Message-----
>> Private Sub Button1_Click(ByVal sender As
>>System.Object, ByVal e As System.EventArgs) Handles
>>Button1.Click
>> TextBox1.MaxLength = 2
>> TextBox1.Text = "Hello"
>>
>> End Sub
>>End Class
>>
>>why when I run this does it display hello instead of he?
>>.
>>

>.
>

 
Reply With Quote
 
Helen of Troy
Guest
Posts: n/a
 
      09-22-2003

The reason is that the internal code which states to display *hello* is
overriding the keyword *MaxLength* even though that line of code occurs
after rather than before.

---
Sign up to get free daily practice questions at: http://www.QoD.US/i-54.htm
View this thread: http://www.examnotes.net/article1022871.html
Helen of Troy

------------------------------------------------------------------------
Helen of Troy's Profile: http://www.examnotes.net/forums/memb...&userid=173331

 
Reply With Quote
 
Kline Sphere
Guest
Posts: n/a
 
      09-22-2003
>So my guess would be that MaxLength only
>affects input (internally on KeyDown)


.... Or on a paste the internal text is set as supplied, although only
maxlength characters are shown (as the doughtier of Tyndarecus has
already said). Using setwindowtext will cause the whole of the text to
be shown, thus ignoring the value of maxlength.
 
Reply With Quote
 
Hassan anwr
Guest
Posts: n/a
 
      10-06-2003

‏‏تم كتابة Jay Walters <(E-Mail Removed)> في أخبار
الرسالة:c0ff01c381e6$9b2c78b0$(E-Mail Removed)...
> - doughtier of Tyndarecus - You're too funny.
>
> >-----Original Message-----
> >>So my guess would be that MaxLength only
> >>affects input (internally on KeyDown)

> >
> >.... Or on a paste the internal text is set as supplied,

> although only
> >maxlength characters are shown (as the doughtier of

> Tyndarecus has
> >already said). Using setwindowtext will cause the whole

> of the text to
> >be shown, thus ignoring the value of maxlength.
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
stupid question...waiting for a stupid answer Brandon McCombs Java 4 08-28-2006 06:57 PM
Stupid question. Please, only stupid responders. If you're not sureif you're stupid, you probably aren't. =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 6 07-18-2005 05:11 AM
Very very very basic question Peter C Programming 14 02-14-2005 09:46 AM
stupid stupid stupid kpg MCSE 17 11-26-2004 02:59 PM
very Very VERY dumb Question About The new Set( ) 's Raymond Arthur St. Marie II of III Python 4 07-27-2003 12:09 AM



Advertisments