我有一个VBA宏,它为其他计算选择用户的数据类型选择。
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
以下是令人讨厌的代码行:
Case IsNumeric = True
我需要做些什么来解决这个问题?我知道IsNumeric是一个内置的VBA功能。
答案 0 :(得分:4)
案例标签应该是值,而不是函数名称。试试
Case True