Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding value of #'s to right of decimal point

Status
Not open for further replies.

johnnyv

Programmer
Jul 13, 2001
216
0
0
CA
just curious more than anything with this one

When using VB I can take the number 3.75 and find out the value of the number to the right of the decimal point In this case 75
can this be done with in vbscript? If so How?

What I need to do is determine if a number stored in a variable can be divided evenly by 4 and if not how much do I need to add to the orginal number to make it divide by 4 evenly

Thanks
 
johnnyv,
I'll take a hack at it...

Code:
Option Explicit

Dim a, b

a = 3.75
b = a - int(a)
b = b * 10 ^ (Len(CStr(b)) - 2) ' subtract 2 from length to account for "0."

Zy
 
Try something like this:
Code:
x="3.75": d=""
i=Instr(x,".")
If i>0 Then d=Mid(x,i+1)
But for your purpose, why don't use the Mod operator ?


Hope This Help
PH.
 
Hello,

My version would be based on fix() more than anything else.

Try with
t=+3.756789
and
t=-3.756789
to see the difference.

s=t-fix(t)
s=fix(s*100) 'n digit : 10^n
wscript.echo s

regards - tsuji
 
thanks guys I will play with it today
 
and one for the cheap seats...
use the split() command, and take the second element in the array

regards
mrmovie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top