• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Dividing Text Lines

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
...etc

Thank You

0
andyakira
Asked:
andyakira
  • 2
1 Solution
 
dkinjalCommented:
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
Wend
-------------------------------------------------------
 
 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...
-Kinjal
0
 
JR2003Commented:
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
0
 
andyakiraAuthor Commented:
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
0
 
dkinjalCommented:
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now