Basic Math and Numbers Issue

waterdog

New Member
Hi all,

Having a small issue with math equation and decimal rounding.

The math is for a metering pump to show how many gallons per day based off of the max speed of the pump, the user set speed, the max gallons per hour, and the percent of stroke on the pump.

the numbers I am using are:

Gallons Per Hour (GPH) = .3
Max Speed = 240
Percent Stroke = 80
User Set Speed = 16

Based off of these numbers, I should return a decimal of .39 The issue is the return is coming back 0.0 and my max Gallons per Day is returning 7.0 instead of 7.2

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim btnBack As Button
   Dim btnCalc As Button
   Dim txtMaxGPH As EditText
   Dim txtMaxSpeed As EditText
   Dim lblMaxGPD As Label
   Dim txtSpeedSet As EditText
   Dim txtStroke As EditText
   Dim lblGPD As Label   
   Dim MaxGPD As Int
   Dim SpeedSet As Int
   Dim Percent As Int
   Dim FullGPD As Int
   Dim SetGPD As Int
End Sub

Sub btnCalc_Click
   MaxGPD = (txtMaxGPH.text * 24)
   lblMaxGPD.Text = (Round2(MaxGPD,2)) 'Makes Max GPD at Max Speed and Stroke
   Percent = (txtStroke.Text *.01) 'Makes Percent Stroke
   SpeedSet = (txtSpeedSet.text / txtMaxSpeed.Text)
   FullGPD = (SpeedSet * lblMaxGPD.Text)
   SetGPD = (FullGPD * Percent)
   lblGPD.Text= (Round2(SetGPD,2))
End Sub

Thanks in advance for the help
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…