View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default Textboxes Not Calculating Properly

I have 4 Textboxes that I use to calculate a length of an outdoor sign.
Height in Feet, Height in Inches, Width in Feet, and Width in Inches. I want
to click a command button and the code will automatically round the height
and width to the nearest 1/16th of an inch. But for some reason when I enter
0.125 or 0.0625 in both of the inch textboxes the numbers returned are not
equal, why?

Private Sub cmbEstimate_Click()

Dim Lheight As Double
Dim Lwidth As Double
Dim Hft As Double
Dim Hins As Double
Dim Wft As Double
Dim Wins As Double

Lheight = Val(tbxHeightFt) + Val(tbxHeightIns) / 12 'face height in ft
MsgBox Lheight
Lwidth = Val(tbxWidthFt) + Val(tbxWidthIns) / 12 'face width in ft
MsgBox Lwidth

'dimensions of cabinet in feet & inches
Hft = Int(Lheight)
MsgBox Hft
Hins = WorksheetFunction.Ceiling((Lheight - Hft) * 12, 0.0625)
MsgBox Hins
Wft = Int(Lwidth)
MsgBox Wft
Wins = WorksheetFunction.Ceiling((Lwidth - Wft) * 12, 0.0625)
MsgBox (Wins)

End Sub

Thanks in Advance,
Ryan