A mistake in 3 simple lines!
Author |
Message |
HazySmoke)345
|
Posted: Fri Mar 10, 2006 7:43 pm Post subject: A mistake in 3 simple lines! |
|
|
Here goes. For this project, you need a textbox called Text1 (Multiline=True), and button called Command1. Under the button, write the following lines:
VisualBASIC: | Private Sub Command1_Click()
MsgBox Len(Text1.Text)
End Sub |
Now run the program. In the textbox, type in the following text:
From my understanding, Len(Text1.Text) should be 11 because there are 9 digits and 2 returns, but when I press the button, it gave me 13. Any explainations for that? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
pavol
|
Posted: Fri Mar 10, 2006 8:32 pm Post subject: (No subject) |
|
|
just a thought, but maybe a space counts as one character and enter counts as two, in which case 13 would make sense |
|
|
|
|
|
GlobeTrotter
|
Posted: Fri Mar 10, 2006 10:34 pm Post subject: (No subject) |
|
|
Yeah, I suspect it is because each new line represents two characters. For example, if you'll notice, the vbNewLine character is actually made of two characters. Thus, 9 letters plus 2*2 vbNewLine = 13 |
|
|
|
|
|
wtd
|
Posted: Sat Mar 11, 2006 4:59 am Post subject: (No subject) |
|
|
Welcome to the wonderful world of Windows. A newline is actually both a carriage return and a linefeed. |
|
|
|
|
|
|
|