Math Functions

# Thread: Math Functions

1. Senior Member
Join Date
Dec 1969
Posts
511

## Math Functions

Can you force a certain amount of decimal places when working out a number and also if the value is less then 10 can you force it to return 08 for instance?

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Just formatting, not math

Look into FORMATNUMBER in the VBScript docs (reference to them in left panel of this very page). If that won&#039;t do exactly what you want, then explain more what you need.<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
511

## RE: Just formatting, not math

The situation is I have a number entered into a text box. its actually a time but to three decimal places. say for instance<BR><BR>1:15.568 and 1:16.658<BR><BR>Niow because of the format I can&#039;t subtract one time from the other. So what I was trying to do was use left and right functions to split into variables like so<BR><BR>f = Request.Form("Time1")<BR>s = Request.Form("Time2")<BR>ftp1 = Left(f, 1)<BR>ftp2 = Right(f, 6)<BR>stp1 = Left(s, 1)<BR>stp2 = Right(s, 6)<BR><BR>And then using math subtract one from the other making sure it still ended up correct but formatted the same way. and then just joing the two variables together using say <BR><BR>MyTime = Timepart1 & ":" & Timepart2<BR><BR>But im failing miserably any advice?

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## How do you know...

...to use LEFT(f,1)???<BR><BR>What happens if the user enters 17 spaces before the number? Or enters 11:13.181122114 ?<BR><BR>f = Split( Trim( Request.Form("Time1") ), ":" )<BR>s = Split( Trim( Request.Form("Time2") ), ":" )<BR>ftp1 = CLNG( f(0))<BR>ftp2 = CDBL( f(1))<BR>stp1 = CLNG( s(1))<BR>stp2 = CDBL( s(2))<BR><BR>Now try working with ftp1, et al.<BR><BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
511

## RE: How do you know...

because im entering the numbers and the number will always be 0 or 1 <BR><BR>just incase i make a mistake though ill add error handline to skip that calculation should the number be above 1 so that i can see an error on the confirm page

#### Posting Permissions

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