VB中很小的一段代码,不知道错哪儿了,提示ByRef参数类型不符,帮忙各位大侠看看啦

2025-01-05 13:54:09
推荐回答(2个)
回答1:

将Public Function fact(x As Long) As Long
改为
Public Function fact(byval x As Long) As Long
应该可以

回答2:

Public Function fact(ByVal x As Long) As Long
Dim i, m As Long
m = 1
For i = 1 To x
m = m * i
Next
fact = m
End Function

Private Sub Form_Click()
Dim k, a As Long
a = 0
For k = 1 To 10
a = a + fact(k)
Next
Print a

End Sub
'byval 指定传值