Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Kiral Demir   on Mar 09 In MS Office Category.

  
Question Answered By: Ty Thompson   on Mar 09

when i remove the declarations from my click button sub it will not
work, saying the variables  are undefined. when i place the
declarations before each sub, i still receive no answer and my
variables are considered "empty"; this is what i have tried following
your advice.


Option Explicit

'dimensionalizing variables
Dim A As Variant
Dim HF As Variant
Dim HI As Variant
Dim BW As Variant
Dim TCM As Variant
Dim TCS As Variant
Dim PeakVO2 As Variant
Dim Treadmill As Boolean
Dim Stairmill As Boolean
Dim Maximal As Boolean
Dim Submaximal As Boolean

Sub MaxVO2Predict()

'dimensionalizing variables
Dim MTInt As Single
Dim MTTC As Single
Dim MTBMI As Single
Dim MSInt As Single
Dim MSTC As Single
Dim MSBMI As Single
Dim ST208Int As Single
Dim ST208TC As Single
Dim ST208BMI As Single
Dim SS208Int As Single
Dim SS208TC As Single
Dim SS208BMI As Single
Dim VO2Input As Object
Dim n As Long

'input prediction equation  coefficients from appropriate cells
MTInt = Sheets("Equations").Cells(8, 14)
MTTC = Sheets("Equations").Cells(9, 14)
MTBMI = Sheets("Equations").Cells(10, 14)
MSInt = Sheets("Equations").Cells(8, 17)
MSTC = Sheets("Equations").Cells(9, 17)
MSBMI = Sheets("Equations").Cells(10, 17)
ST208Int = Sheets("Equations").Cells(15, 4)
ST208TC = Sheets("Equations").Cells(16, 4)
ST208BMI = Sheets("Equations").Cells(17, 4)
SS208Int = Sheets("Equations").Cells(15, 7)
SS208TC = Sheets("Equations").Cells(16, 7)
SS208BMI = Sheets("Equations").Cells(17, 7)

Set VO2Input = New VO2Input
VO2Input.Show

Sheets("Prediction").Cells(22, 2) = A

If Treadmill = True And Maximal = True Then
PeakVO2 = MSInt + ((TCM + (TCS / 60)) * MSTC) + (((BW * 0.453592)
/ (((HF / 12) + HI) * 0.0254) ^ 2) * MSBMI)
ElseIf Stairmill = True And Maximal = True Then
PeakVO2 = MTInt + ((TCM + (TCS / 60)) * MTTC) + (((BW * 0.453592)
/ (((HF / 12) + HI) * 0.0254) ^ 2) * MTBMI)
ElseIf Treadmill = True And Submaximal = True Then
PeakVO2 = ST208Int + ((TCM + (TCS / 60)) * ST208TC) + (((BW *
0.453592) / (((HF / 12) + HI) * 0.0254) ^ 2) * ST208BMI)
ElseIf Stairmill = True And Submaximal = True Then
PeakVO2 = SS208Int + ((TCM + (TCS / 60)) * SS208TC) + (((BW *
0.453592) / (((HF / 12) + HI) * 0.0254) ^ 2) * SS208BMI)
End If

'score is diplayed in appropriate cell
Cells(14, 3) = PeakVO2

'output the answer into the message box
MsgBox ("The predicted maximal oxygen uptake of this subject equals "
& Format(PeakVO2, "##.#") & " mL/kg/min")

n = Sheets("Equations").Cells(19, 14)

'output data from subject into database
Sheets("Data").Cells(2 + n, 1) = (n + 1)
Sheets("Data").Cells(2 + n, 2) = A
Sheets("Data").Cells(2 + n, 3) = (HF / 12) + HI
Sheets("Data").Cells(2 + n, 4) = ((HF / 12) + HI) * 2.54
Sheets("Data").Cells(2 + n, 5) = BW
Sheets("Data").Cells(2 + n, 6) = BW / 2.205
Sheets("Data").Cells(2 + n, 7) = (BW / 2.205) / ((((HF / 12 + HI) *
2.54) / 100) ^ 2)
Sheets("Data").Cells(2 + n, 8) = TCM + (TCS / 60)
Sheets("Data").Cells(2 + n, 9) = PeakVO2
If Stairmill = True Then
Sheets("Data").Cells(2 + n, 10) = "Stairmill"
ElseIf Treadmill = True Then
Sheets("Data").Cells(2 + n, 10) = "Treadmill"
End If
If Maximal = True Then
Sheets("Data").Cells(2 + n, 11) = "Maximal"
ElseIf Submaximal = True Then
Sheets("Data").Cells(2 + n, 11) = "Submaximal"
End If

End Sub

Option Explicit

'dimensionalizing variables
Dim A As Variant
Dim HF As Variant
Dim HI As Variant
Dim BW As Variant
Dim TCM As Variant
Dim TCS As Variant
Dim PeakVO2 As Variant
Dim Treadmill As Boolean
Dim Stairmill As Boolean
Dim Maximal As Boolean
Dim Submaximal As Boolean

Private Sub Enter_Click()

A = InputAge.Value
HF = InputHeightFeet.Value
HI = InputHeightInches.Value
BW = InputWeight.Value
TCM = InputTestTimeMin.Value
TCS = InputTestTimeSeconds.Value
Treadmill = Tread.Value
Stairmill = Stair.Value
Maximal = Max.Value
Submaximal = Submax.Value

Unload VO2Input

End Sub

Private Sub Quit_Click()

Unload VO2Input
End

End Sub

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on custom dialogue box variable entry trouble Or get search suggestion and latest updates.


Tagged: