Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parsing A String and Converting to Int

    I searched the forum and found this:
    Since all variables in ASP are actually of the type "Variant", you shouldn't have to "convert" it to numeric before performing a mathematical operation on it if it is indeed numeric (and I presume you set the cookie!). What are you trying to do, and what kind of information does the cookie contain?

    P.S.
    CInt(variable) = integer
    CDbl(variable) = Double

    and there's plenty more datatypes, look on MSDN
    But I am having trouble converting a passed timer string where:

    Elapsedtime= 'request.form("ElapsedTime")

    Elapsedtime is in the string format: '2:32' or 2 Min 32 Secs.

    I want to parse and get the mod of 232/60 so I can convert to a message of " Your Time Was: 2 Min and 32 Secs"

    Any suggestions, tips or direction will be appreciated.

    TIA

    JoeP

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Why not just get rid of the ":"??

    Mod is easy once you do that...
    Omnis mico antequam dominus Spookster!

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Wait a sec, why are you going to Mod 232 by 60? That will give you the remainder after dividing, if you just split up the variable you can print it as "your time was 2 mins and 32 seconds." easily.

    I might not be getting what you are trying to do but from what my feeble mind is telling me using Mod will achieve nothing. (well nothing that you can use)

    I would just split() it.
    Last edited by Mhtml; 02-16-2003 at 05:34 AM.
    Omnis mico antequam dominus Spookster!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are correct about the Mod.

    What i need is the 2:32 converted to seconds 152.

    LOL, sorry, but I need to know how to split that little : out as well.

    Thx for your time.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Elapsedtime= request.form("ElapsedTime")

    If InStr(1,Elapsedtime,":") Then
    Elapsedtimearray = Split(Elapsedtime,":")
    End If

    If IsArray(Elapsedtimearray) Then
    Response.Write(Elapsedtimearray(0) & " minutes and " Elapsedtimearray(1) & " seconds.<br />" & vbCrLf)
    End If
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you Whammy. That split function is what I was looking for, as I did not know the proper syntax and usage.

    After minor typo in 1st If (it needed an & ) I just added:

    TotalTime =Cint(theElapsedtimearray(0))* 60 + Cint(theElapsedtimearray(1))

    To the 2nd If Statement.

    That gives me total seconds to derive a score I am doing!

    Thx To all, again!

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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