
-----------------------------------
HazySmoke)345
Fri Mar 10, 2006 7:43 pm

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:
Private Sub Command1_Click()
    MsgBox Len(Text1.Text)
End Sub

Now run the program. In the textbox, type in the following text:
123
456
789

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?

-----------------------------------
pavol
Fri Mar 10, 2006 8:32 pm


-----------------------------------
just a thought, but maybe a space counts as one character and enter counts as two, in which case 13 would make sense

-----------------------------------
GlobeTrotter
Fri Mar 10, 2006 10:34 pm


-----------------------------------
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
Sat Mar 11, 2006 4:59 am


-----------------------------------
Welcome to the wonderful world of Windows.  A newline is actually both a carriage return and a linefeed.
