使用VBA與Access 2010,我有一子:多個參數潛艇VBA
Public Sub setInterest(account As String, dmonth As Integer)
...somecode...
End Sub
而且我與
setInterest("myAccount",3)
調用它,我得到的語法錯誤。
修改sub只接受一個參數而忽略3沒有錯誤,問題是隻有當我有2個參數。
使用VBA與Access 2010,我有一子:多個參數潛艇VBA
Public Sub setInterest(account As String, dmonth As Integer)
...somecode...
End Sub
而且我與
setInterest("myAccount",3)
調用它,我得到的語法錯誤。
修改sub只接受一個參數而忽略3沒有錯誤,問題是隻有當我有2個參數。
當使用多個參數,你可以寫:
setInterest "myAccount", 3
或者
Call setInterest("myAccount", 3)
在這兩個例子,你可以命名的參數:
setInterest account:="myAccount", dmonth:= 3
不知道在整個地球上是否有更奇怪的東西!花了兩個小時掙扎着。天啊 :( – 2014-06-10 01:09:30
我補充這個答案,爲爲什麼你的語法只有一個參數?
Public Sub setInterest(account As String)
'...somecode...
End Sub
setInterest ("myAccount")
注:
當沒有(
和)
之間的任何,
,VBA認爲這是一個公式和只有一個參數。
當式計算結果將是這樣的:[在VBA調用子]的
Dim str As String
str = ("TEST")
Debug.Print str
[Output:]
TEST
重複(http://stackoverflow.com/questions/7715044/calling-a-sub- in-vba)......以及其他許多人。這個問題已經被多次解答了。 – 2012-04-14 11:41:14