VB modules
Posted: 2004-04-06 07:32pm
Okey, I'm writing a program to be used to calculate force readings from given values of mass/acceleration (F=ma) or mass/velocity/time (F=m(v/t)). I placed the equations in a module and the command functions in the main (and only) form:
Form code:
Module code:
Now, when I try to execute the program and calculate using either of these options, it gives me a "Expected Function or variable" error. Why's this? I'm a newbie to VB, but shouldn't publicly-declared functions in modules be recognized by forms?
Thanks much.
ADDITION: Whoops, I forgot to say that it points to the MACalc() and MVTCalc() commands within the form code.
Form code:
Code: Select all
Private Sub cmdCalculate_Click()
' If F=ma is selected...
If optMA.Value = True Then
lblReading.Caption = MACalc()
End If
' If F=m(v/t) is selected...
If optMVT.Value = True Then
lblReading.Captain = MVTCalc()
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Code: Select all
Public Sub MACalc()
m = Val(txtMass.Text)
a = Val(txtAcceleration.Text)
F = m * a
End Sub
Public Sub MVTCalc()
m = Val(txtMass.Text)
v = Val(txtVelocity.Text)
t = Val(txtTime.Text)
F = m * (v / t)
End Sub
Thanks much.
ADDITION: Whoops, I forgot to say that it points to the MACalc() and MVTCalc() commands within the form code.