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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to capture the first line in multi-line textbox

Status
Not open for further replies.

Vincentan

MIS
Aug 21, 2002
52
0
0
MY
Hi All, I have a question here and need your advice, I have a textbox which enable multi-line, I have key key few line of the text but I want to program it maybe just capture the first line to field 1 and second line to field 2.

Thanks
 
Dim strText As String
Dim arr() As String
strText = Text1.Text
arr() = Split(strText, vbNewLine)
first line = arr(LBound(arr)) ' arr(0)
second line = arr(1)
end line = arr(UBound(arr))
 
Always test the result of Split for Ubound. TThe rUbu8nd after a Split in VB6 can be -1 as in
Dim aryW() as String
aryW = Split("",",") ' split Zero length string
Msgbox Cstr(Ubound(aryw)) ' = -1

Also there may be fewer elements that you expect.
arr() = Split(strText, vbNewLine)
Dim lngU as Long
lngU = Ubound(arr)
if lngU > -1 then
first line = arr(LBound(arr)) ' arr(0)
if lngU > 0 then
second line = arr(1)
End if
end line = arr(UBound(arr))
end if

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top