2015-06-29 54 views
0

我想调试的代码这个简单的部分:VBA“编译错误:参数不可选”调试子

Public Sub FunctionNotValidVarType() 
MsgBox "VarType " & VarType & " is not supported. Please check spelling." 
End Sub 
+0

Public Sub FunctionNotValidVarType() Dim variable As Integer variable = 2 MsgBox“VarType”&VarType(variable)&“is not supported,please check spelling。”请检查拼写。 End Sub – Gotrekk

+0

由于'VarType'是一个VBA函数,它需要一个变量作为参数传递给它,所以你会得到这个错误。 – Rory

回答

2
Public Sub FunctionNotValidVarType() 
Dim variable As Integer 
variable = 2 
MsgBox "VarType " & VarType(variable) & " is not supported. Please check spelling." 
End Sub 

你需要调用VarType函数传递给它的实际变量

+0

谢谢,我这样做: –

+0

公共BrgSum,BgrVal,Volcorr,MEeff,VarType函数 –

+0

公用Sub FunctionNotValidVarType() VarType函数= CStr的(struserChoice) MSGBOX “VarType函数” 和VarType函数& “不支持,请检查拼写。” 结束子 –