franzkafka
12-06-2008, 07:44 PM
Hello,
I need to populate a text box once the form it is on loads. Its form loads when the user clicks a button on a different form. I want to populate it with a global variable (a double).
The program calculates a flow rate. The user enters some parameters on one form (VariableEntry), clicks "calculate", which gives the variable FlowRate a value and loads the next form (Conclusion). I want that form to contain a text box (FlowRateBox) with the variable FlowRate displayed.
In a module, I have:
Global FlowRate As Double
In the code thing for the first form (VariableEntry), I have:
Private Sub Calculate_Click()
If Not ReynoldsNumberBox.Text = "" And Not PressureBox.Text = "" And Not DiameterBox.Text = "" And Not ViscosityBox.Text = "" And Not PipeLengthBox.Text = "" Then
P = Val(PressureBox.Text)
D = Val(DiameterBox.Text)
V = Val(ViscosityBox.Text)
L = Val(PipeLengthBox.Text)
Const PI As Double = 3.14159265358979
FlowRate = (PI * P * D ^ 4) / (128 * V * L)
Unload VariableEntry
Conclusion.Show
Else
MsgBox "All fields must contain data before flow rate can be calculated"
End If
End Sub
I have been trying this in the code section for the Conclusion form, but it's not working...the text box is just empty:
Private Sub Conclusion_Load()
FlowRateBox = FlowRate
End Sub
I hope I've provided enough information/been clear enough. Thanks. =)
edit:
I think the problem is with the Load() event. Even if I do something like
Private Sub Conclusion_Load()
MsgBox "Hello"
End Sub
the message box doesn't pop up. Is there some trick to getting the load event to work?
I need to populate a text box once the form it is on loads. Its form loads when the user clicks a button on a different form. I want to populate it with a global variable (a double).
The program calculates a flow rate. The user enters some parameters on one form (VariableEntry), clicks "calculate", which gives the variable FlowRate a value and loads the next form (Conclusion). I want that form to contain a text box (FlowRateBox) with the variable FlowRate displayed.
In a module, I have:
Global FlowRate As Double
In the code thing for the first form (VariableEntry), I have:
Private Sub Calculate_Click()
If Not ReynoldsNumberBox.Text = "" And Not PressureBox.Text = "" And Not DiameterBox.Text = "" And Not ViscosityBox.Text = "" And Not PipeLengthBox.Text = "" Then
P = Val(PressureBox.Text)
D = Val(DiameterBox.Text)
V = Val(ViscosityBox.Text)
L = Val(PipeLengthBox.Text)
Const PI As Double = 3.14159265358979
FlowRate = (PI * P * D ^ 4) / (128 * V * L)
Unload VariableEntry
Conclusion.Show
Else
MsgBox "All fields must contain data before flow rate can be calculated"
End If
End Sub
I have been trying this in the code section for the Conclusion form, but it's not working...the text box is just empty:
Private Sub Conclusion_Load()
FlowRateBox = FlowRate
End Sub
I hope I've provided enough information/been clear enough. Thanks. =)
edit:
I think the problem is with the Load() event. Even if I do something like
Private Sub Conclusion_Load()
MsgBox "Hello"
End Sub
the message box doesn't pop up. Is there some trick to getting the load event to work?