VB中函数怎么返回两个返回值
要返回多个值,有几种办法,最直接的就是用传址参数
成都创新互联公司专业为企业提供松北网站建设、松北做网站、松北网站设计、松北网站制作等企业网站建设、网页设计与制作、松北企业网站模板建站服务,十多年松北做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
Function f1(byref retVal1,byref retVal2)
或者用全局变量(比如模块级变量)
或者返回包装过的对象
或者返回多个返回值糅合的字符串
vb.net多线程如何返回参数,举个例子,谢谢
Public Class Form1
Public Class SquareClass '把多线程调用的函数封装到类中,通过类事件返回
Public Value As Double
Public Square As Double
Public Event ThreadComplete(ByVal Square As Double)
Public Sub CalcSquare()
Square = Value * Value
RaiseEvent ThreadComplete(Square)
End Sub
End Class
Dim WithEvents oSquare As SquareClass
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '多线程返回值测试,当线程运行完成激发事件
oSquare = New SquareClass()
Dim t As New Threading.Thread(AddressOf oSquare.CalcSquare)
oSquare.Value = 30
t.Start()
End Sub
Sub SquareEventHandler(ByVal Square As Double) Handles oSquare.ThreadComplete '响应事件函数
MsgBox("The square is " Square)
End Sub
End Class
vb,函数,能不能返回两个值.
不但可以返回两个值,还可以更多。例如 4 个。
Private Sub Command1_Click()
Dim My1 As Boolean, a1 As Long, a2 As String, a3 As Long
My1 = MyFun(1,a1, a2, a3)
'显示返回的 4 个变量的值
Me.Cls
Me.Print My1
Me.Print a1
Me.Print a2
Me.Print a3
End Sub
Private Function MyFun(S as long ,a1 As Long, a2 As String, a3 As Long) As Boolean
MyFun = True
a1 = 100
a2 = "MyStr"
a3 = "200"
End Function
网页标题:vb.net返回两个参数 vbchoose函数返回值
本文链接:http://scgulin.cn/article/doihecd.html