string manipulation

Results 1 to 3 of 3

Thread: string manipulation

  1. #1
    stoke Guest

    Default string manipulation

    here&#039;s my problem<BR>I have a whole lot of strings consisting of mostly numbers. However, some strings have a letter in the beginning.<BR>Is there a way to take only the numeric characters from the strings that have leters?<BR>ie<BR>09174109 -&#062; 09174109<BR>F3498 -&#062; 3498<BR>G298720 -&#062; 298720<BR>89 -&#062; 89<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: string manipulation

    *LOTS* of ways to do this.<BR><BR>If you *KNOW* that the string contains *ONLY* one character that is not a number and you *KNOW* that the character is always at the beginning of the string, then:<BR><BR>&#060;%<BR>theValue = "S123" &#039; or "887" or " X999 " -- note the spaces<BR>&#039; first, get rid of leading/trailing spaces, if any:<BR>theValue = Trim(theValue)<BR>If Not isNumeric( theValue ) Then &#039; if it starts with a letter...<BR>&nbsp; &nbsp; theValue = Mid( theValue, 2 ) &#039; then chop off the letter!<BR>End If<BR>%&#062;<BR><BR>If you *don&#039;t know how many letter there are and if they are mixed anywhere in amongst the numbers, then maybe something like this:<BR><BR>&#060;%<BR>theValue = " X 78: B 87* D 1Z1 "<BR>numOnly = ""<BR>For c = 1 To Len(theValue)<BR>&nbsp; &nbsp; ch = Mid(theValue,c,1)<BR>&nbsp; &nbsp; If ch &#062;= "0" AND ch &#060;= "9" Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; numOnly = numOnly & ch<BR>&nbsp; &nbsp; End If<BR>Next<BR>%&#062;<BR><BR>But there are many other ways, as well.<BR><BR>

  3. #3
    stoke Guest

    Default RE: string manipulation

    ahh, that isNumeric helps out alot, thanks.

Posting Permissions

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