Remove first value from a string

Results 1 to 5 of 5

Thread: Remove first value from a string

  1. #1
    Kok Leong Guest

    Default Remove first value from a string

    I have problem in remove the first value from strings. <BR><BR>My string either contain a value or contains some values where each is seperated with ",". <BR><BR>Current, when I delete any value in strings, it will get rid a "," but not for the first value in my strings. <BR><BR>How should I do when the 1st value of my string is being delete, it will delete a "," as well??<BR><BR>Below is the code of how the deletion is done.<BR><BR>Function RemoveOnce(strExpression, strRemove) <BR>Dim iStartPos, iStopPos, strLeft, strRight <BR>Dim iLeftLen, iRightLen <BR>iStartPos = Instr(1, strExpression, strRemove, 1) <BR>iStopPos = iStartPos + Len(strRemove) - 1 <BR>iLeftLen = iStartPos - 1 <BR>iRightLen = Len(strExpression) - iStopPos <BR>strLeft = Left(strExpression, iLeftLen) <BR>strRight = Right(strExpression, iRightLen) <BR>RemoveOnce = strLeft & strRight <BR>End Function <BR><BR>Function Remove(strExpression, strRemove) <BR>dim aryTemp, intX, strNew <BR>aryTemp = split(strExpression, ",") <BR> <BR>for intX = 0 to ubound(aryTemp) <BR>if aryTemp(intX) &#060;&#062; strRemove then <BR>if intX &#062; 0 then strNew = strNew & "," <BR>strNew = strNew & aryTemp(intX) <BR>remove = strNew <BR><BR>end if<BR>next<BR>end function <BR><BR>TempList = "R1, R2, R3, R4, R5, R6" <BR>NewList = "R1" <BR>TempList = Remove(NewList,Remfile) <BR><BR><BR>Pls help me.. thanks

  2. #2
    Mike Shaffer Guest

    Default ???

    This was answered two days ago when you first asked it. Did that not help?

  3. #3
    Kok Leong Guest

    Default RE: ???

    Well... the solution given is worked except for when the first value of the string is removed.<BR>The result will become like ",R2,R3,R4,R5" if the original string is "R1,R2,R3,R4,R5".

  4. #4
    Mike Shaffer Guest

    Default RE: ???

    Revised:<BR><BR><BR>function Remove(strExpression, strRemove) <BR><BR>&nbsp;&nbsp;&nbsp;dim aryTemp, intX, strNew, boolStarted<BR>&nbsp;&nbsp;&nbsp;boolStarted = False<BR>&nbsp;&nbsp;&nbsp;aryTemp = split(strExpression, ",") <BR>&nbsp;&nbsp;&nbsp;for intX = 0 to ubound(aryTemp) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if aryTemp(intX) &#060;&#062; strRemove then <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;if boolStarted=True then strNew = strNew & "," <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;strNew = strNew & aryTemp(intX) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;boolStarted = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if <BR>&nbsp;&nbsp;&nbsp;next <BR><BR>&nbsp;&nbsp;&nbsp;remove = strNew <BR><BR>end function <BR>

  5. #5
    Kok Leong Guest

    Default RE: ???

    Thanks Mike... is working now...

Posting Permissions

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