Dividing Text Lines

Posted on 2004-08-08
Last Modified: 2010-04-17
I'm working with VB6, and trying to divide whatever text is in the textbox into sections.
for example lets say the text box contains ascii art:

---------------------   <- line1
                }}}         <- line2
}}}   }}}                 <- line3
}}}   }}}    }}}         <- line4
}}}}}}}}    }}}         <- line5
}}}  }}}}   }}}          <- line6
                              <- line7
--------------------     <- line8

I need to do something like this:

SendtoChat Line1
SendtoChat Line2
SendtoChat Line3

Thank You

Question by:andyakira
  • 2

Expert Comment

ID: 11750876
hi andyakira,
its easy to do its... just have the code below:

Dim fname As String, str As String,fno as Integer
fname = "c:\windows\desktop\new.txt"
fno = FreeFile()
Open fname For Input As #fno
While Not EOF(1)
     Line Input #fno, str
     SendToChat str
 You need to change the code according to your requirement.. I mean, in particular, the path should be replaced by your file path.... Well hope it will solve your matter...
LVL 18

Accepted Solution

JR2003 earned 30 total points
ID: 11751041
1 Convert the text in the multiline text box into a variant array.
2 Iterate through the array sending the individula lines to chat:

Private Sub Command1_Click()

    Dim MyLines As Variant
    Dim i As Long
    MyLines = Split(Text1.Text, vbNewLine)
    For i = LBound(MyLines) To UBound(MyLines)
        'SendtoChat MyLines(i)
        Debug.Print MyLines(i)
    Next i

End Sub

Author Comment

ID: 11759185
Thank you both for helping, greatly appreciated. keep up the good work guys!

 JR2003, the code works perfectly, i just put it in and it worked with hardly any adjustments done. TY

Expert Comment

ID: 11760205
ohh.. i was just in hurry and merged up both the questions and felt that this question is for extracting from file.... the code i posted was for that... sorry for that... bye

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question