i have declared a global variable at the top of my main form underneath option explicit.
However i get this message no matter where on the form i place the global variable declaration >>
ERROR MESSAGE READS:
constants, fixed length strings, arrays, user defined types and declare statements not allowed as public members of object modules
heres my code:
Option Explicit
Global gCost As Currency
Private Sub CMDend_Click()
Dim iReply As Integer
iReply = MsgBox("Exit the program?", vbYesNo + vbQuestion, "Exit?"
If iReply = vbYes Then End
End Sub
Private Sub cmdReg_Click()
FRMmain.Hide
frmPrvtReg.Show
End Sub
Private Sub form_load()
CBOmodel.AddItem "Hatch Back"
CBOmodel.AddItem "Saloon"
CBOmodel.AddItem "Sports"
End Sub
Private Sub cmdReview_Click()
Dim cModelCost As Currency
Dim cPtx As Currency
'puts values to list options
Select Case CBOmodel.ListIndex
Case 0: cModelCost = 9000
Case 1: cModelCost = 11000
Case 2: cModelCost = 13000
End Select
'data validation, checks if model has been selected
If CBOmodel.Text = "" Then
MsgBox "Must select a model", vbOKOnly, "Model?"
Else
gCost = cModelCost - cPtx
End If
'dowhile CBOmodel.Text != ""
FRMmain.Hide
frmCheckout.Show
End Sub
Private Sub CMDptx_Click()
Const cMaxPtx = 13000
cPtx = 0
'read in the price of old car
cPtx = InputBox("Please enter car worth", "Enter Value"
If cPtx > cMaxPtx Then
MsgBox " Your car is worth more than what we have for sale ", vbOKOnly, "R U Sure?"
End If
End Sub
Many Thanks, Janet
However i get this message no matter where on the form i place the global variable declaration >>
ERROR MESSAGE READS:
constants, fixed length strings, arrays, user defined types and declare statements not allowed as public members of object modules
heres my code:
Option Explicit
Global gCost As Currency
Private Sub CMDend_Click()
Dim iReply As Integer
iReply = MsgBox("Exit the program?", vbYesNo + vbQuestion, "Exit?"
If iReply = vbYes Then End
End Sub
Private Sub cmdReg_Click()
FRMmain.Hide
frmPrvtReg.Show
End Sub
Private Sub form_load()
CBOmodel.AddItem "Hatch Back"
CBOmodel.AddItem "Saloon"
CBOmodel.AddItem "Sports"
End Sub
Private Sub cmdReview_Click()
Dim cModelCost As Currency
Dim cPtx As Currency
'puts values to list options
Select Case CBOmodel.ListIndex
Case 0: cModelCost = 9000
Case 1: cModelCost = 11000
Case 2: cModelCost = 13000
End Select
'data validation, checks if model has been selected
If CBOmodel.Text = "" Then
MsgBox "Must select a model", vbOKOnly, "Model?"
Else
gCost = cModelCost - cPtx
End If
'dowhile CBOmodel.Text != ""
FRMmain.Hide
frmCheckout.Show
End Sub
Private Sub CMDptx_Click()
Const cMaxPtx = 13000
cPtx = 0
'read in the price of old car
cPtx = InputBox("Please enter car worth", "Enter Value"
If cPtx > cMaxPtx Then
MsgBox " Your car is worth more than what we have for sale ", vbOKOnly, "R U Sure?"
End If
End Sub
Many Thanks, Janet