Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 To: Rosalyn Panganoron
  Where is Rosalyn Panganoron?
 Tagum
 Philippines
 Rosalyn Panganoron
 Tags
Subject: RE: returning numeric without rounding off
Thread ID: 189031 Message ID: 189111 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Wednesday, August 13, 2008 12:48:38 PM         
   


> hi there...what function shall i use if i want to return a numeric data upto two decimal places only without rounding it off...for example i have 6.778, i want to return only 6.77



This is a small code to do that with dialog box and any number.

set fixed off    &&needed
set deci to 18
CLEAR
x = INPUTBOX("Type Here:", "Input Title",  ;
"", 5000, 'Timed Out', 'Canceled')   &&input any number
xx=val(x)
****************
ndec=2  &&2 decimals here but can put any number<=18
xent=int(xx)
p0=at('.',trans(xx),1)
if p0>0
xdec=substr(trans(xx),p0+1)
else
xdec=""
endi
xreturn=trans(xent)+"."+substr(xdec,1,ndec)
messagebox(x+"......return="+xreturn)
set deci to 2
set fixed on
?val(xreturn)
return

regards
Yousfi Benameur

ENTIRE THREAD

returning numeric without rounding off Posted by rosalyn panganoron @ 8/13/2008 3:08:17 AM
RE: returning numeric without rounding off Posted by Glenn Villar @ 8/13/2008 3:49:06 AM
RE: returning numeric without rounding off Posted by mike castillo @ 8/13/2008 3:59:45 AM
RE: returning numeric without rounding off Posted by tushar @ 8/13/2008 5:19:27 AM
RE: returning numeric without rounding off Posted by Yousfi Benameur @ 8/13/2008 12:48:38 PM