Reputation:
I have a VBA macro which selects the user's data type choice for other calculations.
Sub Function1()
' Give the user macro options based on how fast or slow the computer is using advanced conditional compliling
MsgBox ("This macro by default treats all numbers as decimals for maximum precision. If you are running this macro on an old computer, you may want to relare numbers as singles, to speed up the macro.")
MsgBox ("Decimals are reccomended for any scientific conclusions.")
MsgBox ("Decimal: reccomended for maximum precision. Also slower." & vbNewLine & "Double: not reccomended." & vbNewLine & "Single: not reccomended. A lightweight double." & vbNewLine & "Long: rounds to nearest number. Massive range of possible values." & vbNewLine & "Integer: designed for quick estimates of data.")
vuserChoice = InputBox("Select a data type:" & vbNewLine & "1. Decimal" & vbNewLine & "2. Long" & vbNewLine & "3. Single" & vbNewLine & "5. Integer")
Select Case IsNumeric(vuserChoice)
Case IsNumeric = True
MsgBox ("A number cannot be entered for data type.")
Case IsNumeric = False
struserChoice = CStr(vuserChoice)
If struserChoice = "Decimal" Or "decimal" Or "1" Or "one" Or "on" Or "Dec" Or "dec" Then
Call FunctionDecimal
ElseIf struserChoice = "Double" Or "double" Or "2" Or "two" Or "to" Then
FunctionDouble
ElseIf struserChoice = "Single" Or "single" Or "3" Or "three" Or "three" Or "thee" Then
FunctionSingle
ElseIf struserChoice = "Long" Or "long" Or "4" Or "four" Or "for" Or "foor" Then
FunctionLong
ElseIf struserChoice = "Integer" Or "integer" Or "int" Then
FunctionInteger
Else
FunctionNotValidVarType
End If
' MEeff = measure of efflux due to crudely purified HDL in scintillation
MsgBox "For additional information about this macro:" & vbNewLine & "1. Go to tab Developer" & vbNewLine & "2. Select Visual Basic or Macro." & vbNewLine & "See the comments or MsgBoxes (message boxes)."
End Sub
Here is the offending line of code:
Case IsNumeric = True
What do I need to do to fix this? I know IsNumeric is a built-in VBA feature.
Upvotes: 0
Views: 1065
Reputation: 51998
The case labels should be values, not function names. Try
Case True
Upvotes: 3