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

cut string into two 1

Status
Not open for further replies.

holidayIT

IS-IT--Management
Apr 2, 2004
138
US
i need to take a string, and cut it into two strings where neither string is bigger than 254. i'd prefer the first to be 254 in length, and i used to know how to do it in vb6, but cannot remember. if anyone knows how to do this in vb.net i would REALLY appreciate it.
 
does anyone know if this will work?

totalLen = Len(var)
var1 = lset(var, 254)
totalLen = totalLen -254
var2 = rset(var, totalLen)
 
Try something like:-

Dim str As String
Dim arr() As String
Dim i As Integer

str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

ReDim arr(0)

Do Until str.Length < 255
arr(arr.GetUpperBound(0)) = Left(str, 255)
ReDim Preserve arr(arr.GetUpperBound(0))
str = Mid(str, 256)
Loop

arr(arr.GetUpperBound(0)) = str

For i = 0 To arr.GetUpperBound(0)
Debug.WriteLine(i & ":" & arr(i).Length)
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top