SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    ASP: CInt question

    If I have a string and use CInt on it, it will drop all numeric characters, correct?
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here you go sunny, this is some info u might find usefull http://share.intelidev.com/index.asp...item=vsfctcint curtesy of james

  3. #3
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thanx for both answers (to the other question too, I may need to get you to email it as I closed the msn window *L*).

    Anyways, that doesn't really seem to answer my question...

    My question is... if I had:

    a="a911a"
    b=CInt(a)
    response.write b

    Would it return 911 or invalid? I could test it tomorrow on the server, but I'm at home now
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  4. #4
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doing
    a="a911a"
    b=CInt(a)
    response.write b
    will cos an error, but i think i get what u mean now, so i wrote a function for ya also added in a lil more at no extra cost

    Code:
    function sortStr(str,strT)
    	strLen = len(str)
    	strCount = 1
    	Do Until strCount = strLen + 1
    		tLetter = left(str, 1)
    		If strT = 1 then
    			If isNumeric(tLetter) then
    				tStr = tStr + tLetter
    			end if
    		elseif strT = 2 then
    			If NOT isNumeric(tLetter) then
    				tStr = tStr + tLetter
    			end if
    		end if
    		str = right(str, strLen - strCount)
    		strCount = strCount + 1
    	Loop
    	sortStr = tStr
    end function
    response.write(sortStr("a1a2a3a4a5a6a7a8a9", 1) & "</p>" & sortStr("a1a2a3a4a5a6a7a8a9", 2))
    thats will return 123456789 and aaaaaaaaa. to parse out number, use sortStr(str, 1) and to parse letter use sortStr(str, 2)

    i hope its what you looking for.

    BTW the answer to the other question is in the actual post here in the forum


Bookmarks

Posting Permissions

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