Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 A mistake in 3 simple lines!
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HazySmoke)345




PostPosted: 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:
code:
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?
Sponsor
Sponsor
Sponsor
sponsor
pavol




PostPosted: 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




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: