Private Sub Command1_Click()Call maxt = hand1 End SubPublic hand1 As String Public Sub max()hand1 = "True" End Sub
纠正一点:想要让函数有返回值,要用Function 而不是Sub 两种方法: 当返回参数只有一个时:函数名作为回传变量Private Sub Command1_Click() dim t as boolean t=max End SubPublic function max() as Boolean Dim hand1 As Boolean hand1 = True max=hand1 End Sub当有多个函数返回值时:用以下的函数形式Public function max(byref a as string,byref b as boolean) a="First Var" b=true End Sub
End SubPublic hand1 As String
Public Sub max()hand1 = "True"
End Sub
两种方法:
当返回参数只有一个时:函数名作为回传变量Private Sub Command1_Click()
dim t as boolean
t=max
End SubPublic function max() as Boolean
Dim hand1 As Boolean
hand1 = True
max=hand1
End Sub当有多个函数返回值时:用以下的函数形式Public function max(byref a as string,byref b as boolean)
a="First Var"
b=true
End Sub