S
Sam Kuo
How do I reference a constant number in VBA? Thanks in advance
'Below is my example code
Private Sub cmdShowMsg_Click
Dim ControlType As Variant
Dim ControlValue 'what data type should this be?
Const ControlDE As Long = 60
Const ControlSF As Long = 70
Const ControlSSF As Long = 80
Const ControlSRPS As Long = 50
Const ControlSRPW As Long = 75
Const ControlFSRPS As Long = 75
Const ControlFSRPW As Long = 95
With UserForm1
For Each ControlType In Split("DE,SF,SSF,SRPS,SRPW,FSRPS,FSRPW", ",")
'how can I reference the ControlValue
'to return the matching constant value, instead of name?
ControlValue = "Control" & ControlType
If .Controls("txtControl" & ControlType).Value <> ControlValue
Then
MsgBox "Contrl value for" & ControlType & " is NOT " &
ControlValue
Else
MsgBox "Contrl value for" & ControlType & " is " &
ControlValue
End If
Next ControlType
End With
End Sub
'Below is my example code
Private Sub cmdShowMsg_Click
Dim ControlType As Variant
Dim ControlValue 'what data type should this be?
Const ControlDE As Long = 60
Const ControlSF As Long = 70
Const ControlSSF As Long = 80
Const ControlSRPS As Long = 50
Const ControlSRPW As Long = 75
Const ControlFSRPS As Long = 75
Const ControlFSRPW As Long = 95
With UserForm1
For Each ControlType In Split("DE,SF,SSF,SRPS,SRPW,FSRPS,FSRPW", ",")
'how can I reference the ControlValue
'to return the matching constant value, instead of name?
ControlValue = "Control" & ControlType
If .Controls("txtControl" & ControlType).Value <> ControlValue
Then
MsgBox "Contrl value for" & ControlType & " is NOT " &
ControlValue
Else
MsgBox "Contrl value for" & ControlType & " is " &
ControlValue
End If
Next ControlType
End With
End Sub