Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a certain portion of a line

Status
Not open for further replies.

Vec

IS-IT--Management
Jan 29, 2002
418
US
If I want to read a certain line of a text box, and then place that string of data in another text box, I do it like this:

Private Sub Command1_Click()
Dim vlines() As String
vlines = Split(Text1.Text, vbCrLf)
Text2.Text = Mid$(vlines(1), 25)
End Sub

The above code reads line 1 of information of multiline Text1.Text and then places it in Text2.Text and it takes the text from the 25th character of that line forward.

BUT.....how do I start at the 25th character and stop at the 30th?

Can someone please modify the above code to show me an example of how to do it?

Thanks
 
If by LINE 1 you mean the first line then change
Text2.Text = Mid$(vlines(1), 25,5)
to
Text2.Text = Mid$(vlines(0), 25,5)
If by STOP AT THE 30TH character you mean to include the 30TH then change
Text2.Text = Mid$(vlines(0), 25,5)
to
Text2.Text = Mid$(vlines(0), 25,6)



Compare Code (Text)
Generate Sort in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top