Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi!
In vb6 I use the command:
For Each Line In Text1.Text
but this doesn't work, any suggestions?so sick of vb, never works as supposed to
/thanks in advance
Live The Life As You Know It

It sounds like you haven't read the manual properly. Why do you think it never works as it's supposed to? Why do you think you can iterate over a string? The For Each command only iterates over collections and arrays. The Text property is just a String.

Let me try again. Text1.Text is a single string, so you can just print it out like a string variable. If your text box is multi-line, the string is still a single string but it contains carriage return characters (chr(13)) to delimit each line. As for a manual, you don't actually need one, as the F1 Help facility contains much useful information to get you going. However, if you have come from an old, procedural type of Basic language (such as the ones you used to get on the old DOS systems), you'll need to know a little bit about object-oriented programming in order to use VB effectively.

If you don understand what klint was trying to tell you then you need to go back to basics and learn the difference between strings, variables, collections and arrays. Fundamental stuff in any programming language.
There is only one Text1.text so for each is meaningless in this context. However if text1.text was part of an array, e.g text1(0)text, text1(1).text, etc, then it would work. If you learn nothing else, learn about arrays. Very powerful concepts when used properly
The entire VB6 documentation is available on-line - all you ever needed to know about VB6. All you have to do is read it.
http://msdn2.microsoft.com/en-us/li...
Stuart

In VB.Net, all variable types are derived from the object class. Therefore on "may" iterate using the For...Each loop. No. But then it doesent hurt to read the manual
You can argue, fight and quarrel all you want, but at the end of the day you will have a headache

![]() |
XEX to EXE/COM conversion
|
Dos (?)
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |