I am working on a Concrete & Dirt Calculator. I keep getting 0.0 in all the output labels in final layout. This could also be a issue w/the radio buttons?
There are 4 modules:
Main (just instructions begin button)
InputSet (calculator ui for user to input length & width values stored in Globals)
HeightSet (8 radio buttons for user to select a hight value stored in Globals)
Calculated (User to click calculate button and fields return result based on calulations using Globals)
Process_Globals
(InputSet Module) Calculation after user inters length & height
(HeightSet Module) Sub Globals
User picks height by Radio Button
(Calculate Module) Sub_Globals
Calculation/Exit
Not sure what I'm doing wrong:sign0104:
There are 4 modules:
Main (just instructions begin button)
InputSet (calculator ui for user to input length & width values stored in Globals)
HeightSet (8 radio buttons for user to select a hight value stored in Globals)
Calculated (User to click calculate button and fields return result based on calulations using Globals)
Process_Globals
B4X:
Dim inputLength As Double
Dim inputHeight As Double
Dim inputWidth As Double
Dim calulation As Double
Dim setLayout As Int
Dim reset
Dim Total As Double
(InputSet Module) Calculation after user inters length & height
B4X:
Sub btnAction_Click
Dim numb1 As Int
Dim numb2 As Int
'sets the transition between inputs length, width, height, and final calcualtion
If setLayout = 1 Then
numb1 = lblResult.Text
inputWidth = numb1
lblComments.Text = "Enter project width" & CRLF & "and click on OK"
setLayout = 2
lblResult.Text = ""
Else If setLayout = 2 Then
numb2 = lblResult.Text
inputLength = numb2
lblComments.Text = "Enter project length" & CRLF & "and click on OK"
setLayout = 3
lblResult.Text = ""
End If
If setLayout = 3 Then
StartActivity("HeightSet")
End If
End Sub
(HeightSet Module) Sub Globals
B4X:
Dim RadioButton1 As RadioButton
Dim RadioButton2 As RadioButton
Dim RadioButton3 As RadioButton
Dim RadioButton4 As RadioButton
Dim RadioButton5 As RadioButton
Dim RadioButton6 As RadioButton
Dim RadioButton7 As RadioButton
Dim RadioButton8 As RadioButton
Dim lblResult As Label
Dim lblComments As Label
Dim num1, num2, num3, num4, num5, num6, num7, num8 As Double
User picks height by Radio Button
B4X:
Sub RadioButtion1_CheckedChange(Chkd As Boolean)
Dim inputHeight As Double
If Chkd Then
num1 = .0833
inputHeight = num1
End If
End Sub
Sub RadioButtion2_CheckedChange(Chkd As Boolean)
If Chkd Then
num2 = .0666
inputHeight = num2
End If
[COLOR="Lime"]'and so on for 8 radio buttons[/COLOR]
End Sub
End Sub
(Calculate Module) Sub_Globals
B4X:
Dim Label1 As Label
Dim Label2 As Label
Dim Label3 As Label
Dim lblExtraYards As Label
Dim lblExtraEight As Label
Dim lblExtraSix As Label
Dim btnNewCalc As Button
Dim yrds, sixty, eighty, yrdsExtra, sixtyExtra, eightyExtra As Double
End Sub
Calculation/Exit
B4X:
Sub btnNewCalc_Click ()
If btnNewCalc.text = "Calculate" Then
Total = inputLength * inputWidth * inputHeight
'yards calculation
Total = yrds
Label1.Text = yrds
'60 lb bag calculation
sixty = Total * .017
Label2.Text = sixty
'80 lb bag calculation
eighty = Total * 45
Label3.Text = eighty
'set yard extra
yrdsExtra = (Total * .15) + Total
'lblExtraYards.Text = yrdsExtra
'set extra % 60lb
sixtyExtra = (sixty * .15) + Total
lblExtraSix.Text = sixtyExtra
'set extra % 80lb
eightyExtra = (eighty * .15) + Total
lblExtraEight.Text = eightyExtra
btnNewCalc.Text = "New Calculation"
Else
inputWidth = 0
inputLength = 0
inputHeight = 0
StartActivity("InputSet")
End If
End Sub
Sub btnExit_Click
inputWidth = 0
inputLength = 0
inputHeight = 0
ExitApplication
End Sub
Not sure what I'm doing wrong:sign0104: