新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Sub Command1_Click()
Dim str1, str2 As String
MsgBox f_test(str1)
End Sub
Private Function f_test(str1 As String) As String
f_test = "码农库"
End Function
提示错误:ByRef参数类型不符。改成:
Private Sub Command1_Click()
Dim str1 As String
Dim str2 As String
MsgBox f_test(str1)
End Sub
Private Function f_test(str1 As String) As String
f_test = "码农库"
End Function
后正确。sub也同理。
Private Sub Command1_Click()
Dim str1 As String
Dim str2 As String
Call s_test(str1)
End Sub
Private Sub s_test(str1 As String)
MsgBox "码农库"
End Sub
才对,而Dim str1, str2 As String会错误。