Breaking up strings in ASP

Results 1 to 3 of 3

Thread: Breaking up strings in ASP

  1. #1
    Testie Guest

    Default Breaking up strings in ASP

    Is there any way to break a string down in to 2 parts then write these seperate columns in a database?<BR>Something simalar to the Javascript .split function would be a god send.<BR>All Comments Welcomed

  2. #2
    Join Date
    Dec 1969

    Default RE: Breaking up strings in ASP

    &#060;%<BR>Function TLsplit(StrToSplit,Delim)<BR>Dim StrArray()<BR>If StrToSplit = "" Then<BR> ReDim StrArray(1)<BR> StrArray(0) = 0<BR> StrArray(1) = ""<BR> TLsplit = StrArray<BR>Else<BR> dcount = 0<BR> For TLsI = 1 To Len(StrToSplit)<BR> If Mid(StrToSplit,TLsI,1) = Delim Then dCount = dCount + 1<BR> Next<BR> If dCount = 0 Then<BR> ReDim StrArray(1)<BR> StrArray(0) = 1<BR> StrArray(1) = StrToSplit<BR> TLsplit = StrArray<BR> Else<BR> ReDim StrArray(dCount + 1)<BR> StrArray(0) = dCount + 1<BR> TempArray = Split(StrToSplit,Delim)<BR> For TLsI = 1 To dCount + 1<BR> StrArray(TLsI) = Trim(TempArray(TLsI - 1))<BR>TLsplit = StrArray<BR> Next<BR> End If<BR>End If<BR>End Function<BR>%&#062;<BR><BR>&#060;% RandomVariable = "This,is,a,dynamic,split,function" %&#062;<BR><BR>&#060;%<BR>TestArray = TLsplit(RandomVariable, ",")<BR>For I = 1 To TestArray(0)<BR>&#039*************put into the database here<BR>Response.Write("TestArray(" & I & ") = " & TestArray(I) & "<BR>")<BR>Next<BR>%&#062;<BR>

  3. #3
    Panos Barbalias Guest

    Default RE: Breaking up strings in ASP

    You can always use VB&#039s Right or Left to take the string in two parts, if you know from the beginning the length of the string..Or, add a function to count the characters in the string.<BR><BR>You can always use Split since VBscript supports it.Here&#039s the syntax:<BR>Split(expression, delimiter, count, comparetype) takes a string and splits it up into an array of strings.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts