Robert Treadwell
asked on
Round Double Type value to Two decimal place in lotuscript
How do you round 4.68079444599355E-04 to two decimal places. Lotusscript Rounding returns 0 and Evaluate @Round return OverFlow Error.
Here is my code.
'Initialize Varibles
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim doc, pdoc As notesDocument
Dim PCDayWk100 As Integer 'User Entry
Dim NCDayWk100 As Double
Dim NCDayWk120 As Double
Dim Yrly100Demand As Double
Dim SecPerHr As Integer 'Profile Retrieved
Dim HrsPerShift As Double 'Profile Retrieved
Dim NoOfShifts As Double 'User Entry
Dim DayPerYr As Double 'Profile Retrieved
Dim PCT As Double'User Entry
Dim NoOfLines As Double 'User Entry
Dim PCYrlyDemand As Double
Dim dataEntrySum As Double
Dim PCYrlyDemandDivDataEntrySu m As Double
'Set Variables
Set db = ses.CurrentDatabase
Set pdoc = db.GetProfileDocument("DBP rofile")
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
If Not uidoc.FieldGetText("PCDayW k100") = "" Then
PCDayWk100= uidoc.FieldGetText("PCDayW k100")
NoOfShifts= uidoc.FieldGetText("NoOfSh ifts")
Yrly100Demand = getYrlyDemandCol(db, doc.WrkCellID(0))
PCT= uidoc.FieldGetText("PCT")
HrsPerShift = pdoc.HrPerShift(0)
DayPerYr = pdoc.DaysPerYear(0)
SecPerHr = pdoc.SecPerHr(0)
NoOfLines = doc.NoLines(0)
'Perform Calculation
PCYrlyDemand = PCDayWk100 * Yrly100Demand
dataEntrySum = NoOfLines * SecPerHr * HrsPerShift * NoOfShifts * DayPerYr
'dataEntrySumDivPCT = dataEntrySum / PCT
PCYrlyDemandDivDataEntrySu m = PCYrlyDemand / dataEntrySum
NCDayWk100 =PCYrlyDemandDivDataEntryS um / PCT
newValue = Evaluate("@Round(" & NCDayWk100 & ", 2)")
Call uidoc.FieldSetText("NCDayW k100", Cstr(NCDayWk100))
'Set Needed Capacity @120%
NCDayWk120= NCDayWk100 * 1.2
Call uidoc.FieldSetText("NCDayW k120", Cstr(NCDayWk120))
End If
Here is my code.
'Initialize Varibles
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim doc, pdoc As notesDocument
Dim PCDayWk100 As Integer 'User Entry
Dim NCDayWk100 As Double
Dim NCDayWk120 As Double
Dim Yrly100Demand As Double
Dim SecPerHr As Integer 'Profile Retrieved
Dim HrsPerShift As Double 'Profile Retrieved
Dim NoOfShifts As Double 'User Entry
Dim DayPerYr As Double 'Profile Retrieved
Dim PCT As Double'User Entry
Dim NoOfLines As Double 'User Entry
Dim PCYrlyDemand As Double
Dim dataEntrySum As Double
Dim PCYrlyDemandDivDataEntrySu
'Set Variables
Set db = ses.CurrentDatabase
Set pdoc = db.GetProfileDocument("DBP
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
If Not uidoc.FieldGetText("PCDayW
PCDayWk100= uidoc.FieldGetText("PCDayW
NoOfShifts= uidoc.FieldGetText("NoOfSh
Yrly100Demand = getYrlyDemandCol(db, doc.WrkCellID(0))
PCT= uidoc.FieldGetText("PCT")
HrsPerShift = pdoc.HrPerShift(0)
DayPerYr = pdoc.DaysPerYear(0)
SecPerHr = pdoc.SecPerHr(0)
NoOfLines = doc.NoLines(0)
'Perform Calculation
PCYrlyDemand = PCDayWk100 * Yrly100Demand
dataEntrySum = NoOfLines * SecPerHr * HrsPerShift * NoOfShifts * DayPerYr
'dataEntrySumDivPCT = dataEntrySum / PCT
PCYrlyDemandDivDataEntrySu
NCDayWk100 =PCYrlyDemandDivDataEntryS
newValue = Evaluate("@Round(" & NCDayWk100 & ", 2)")
Call uidoc.FieldSetText("NCDayW
'Set Needed Capacity @120%
NCDayWk120= NCDayWk100 * 1.2
Call uidoc.FieldSetText("NCDayW
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have good eyes, Sir! :-)
As far as the Overflow Error is concerned:
newValue = Evaluate("@Round(" & NCDayWk100 & ", 2)")
contains a formula error. Try to find the four-pixel difference with this line:
newValue = Evaluate("@Round(" & NCDayWk100 & "; 2)")
Points to Dragon-IT!
As far as the Overflow Error is concerned:
newValue = Evaluate("@Round(" & NCDayWk100 & ", 2)")
contains a formula error. Try to find the four-pixel difference with this line:
newValue = Evaluate("@Round(" & NCDayWk100 & "; 2)")
Points to Dragon-IT!
Yes good point there Sjef, I didn't actually look at the evaluated command since I knew it was going to be 0 (or error in this case).
Steve
Steve
rtreadwell - are you there?
Well thankyou for the points and grade.... tipped me over into being a "Guru" apparently ... another 10 years and could make a wizard if Notes is still around...
Lotus Notes points: 151546
148454 more points to become a Wizard in Lotus Notes!
Steve
Lotus Notes points: 151546
148454 more points to become a Wizard in Lotus Notes!
Steve
Congrats! And a little focus might get you there sooner... :-)
Yeah, inbetween running a business, fixing everyone else's problems and looking after the kids you mean :-)
BUT 4.68079444599355E-04 = 0.000468079444599355
So rounded to two spaces it IS "0"
Steve