線程結(jié)束后利用委托生成事件返回,線程應(yīng)用包括傳入和傳出參數(shù)。
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名注冊(cè)、網(wǎng)站空間、營(yíng)銷(xiāo)軟件、網(wǎng)站建設(shè)、銅川網(wǎng)站維護(hù)、網(wǎng)站推廣。
Public Delegate Sub ThreadCallback(value As ThreadResult)
Public Class Form1
Private WithEvents _th_1 As Thread_1
Protected Overrides Sub OnLoad(e As System.EventArgs)
Dim value As ThreadObject
value.Index = 1
Me._th_1 = New Thread_1(Me)
Me._th_1.Run(value)
MyBase.OnLoad(e)
End Sub
Private Sub Thread_1_End(sender As Object, e As ThreadEventArgs) Handles _th_1.ThreadEnd
Me.TextBox1.Text = e.Result.Text
End Sub
End Class
Public Class Thread_1
Public Event ThreadEnd(sender As Object, e As ThreadEventArgs)
Private _control As Control
Sub New(control As Control)
Me._control = control
End Sub
Public Sub Run(value As Object)
Dim th As New Threading.Thread(AddressOf ThreadProc)
th.Start(value)
End Sub
Private Sub ThreadProc(obj As Object)
Dim value As ThreadObject = CType(obj, ThreadObject)
Dim result As ThreadResult = Nothing
If value.Index = 1 Then result.Text = "測(cè)試"
Dim callback As New ThreadCallback(AddressOf ThreadInvoke)
_control.Invoke(callback, result)
End Sub
Private Sub ThreadInvoke(value As ThreadResult)
RaiseEvent ThreadEnd(Me, New ThreadEventArgs(value))
End Sub
End Class
Public Structure ThreadObject
Public Index As Integer
'Public Rect As Rectangle
End Structure
Public Structure ThreadResult
Public Text As String
'Public Rect As Rectangle
End Structure
Public Class ThreadEventArgs
Inherits System.EventArgs
Private _result As ThreadResult
Public ReadOnly Property Result As ThreadResult
Get
Return _result
End Get
End Property
Sub New(value As ThreadResult)
Me._result = value
End Sub
End Class
兩個(gè)參數(shù):一個(gè)是數(shù)組名,一個(gè)是傳遞的長(zhǎng)度
Function thename(ByVal imgFrom As Image) As String
thename = imgFrom.Name
End Function
Private Sub Image1_Click()
MsgBox thename(Image1)
End Sub
新窗體中寫(xiě)
構(gòu)造函數(shù)
,然后調(diào)用。
比如你要調(diào)用的新窗體是From1.cs這個(gè)窗體,
public
Form1(要傳入的參數(shù))
{
//把傳入的參數(shù)傳入窗體中
//執(zhí)行窗體標(biāo)準(zhǔn)內(nèi)容
}
然后在需要調(diào)用的地方調(diào)用
Form1
f
=
new
Form1(傳出的參數(shù));
'--------Form1--------
Dim
f2
As
Form2
Private
Sub
Command1_Click()
Set
f2
=
New
Form2
f2.Show
vbModal
End
Sub
'--------Form1
End--------
'--------Form2--------
Dim
WithEvents
f3
As
Form3
Private
Sub
Command1_Click()
Set
f3
=
New
Form3
f3.Show
End
Sub
Public
Sub
f3_f2W()
Me.Command1.Caption
=
"f2W"
End
Sub
'--------Form2
End--------
'--------Form3--------
Public
Event
f2W()
Private
Sub
Command1_Click()
RaiseEvent
f2W
End
Sub
'--------Form3
End--------
f.Show();
如此就能實(shí)現(xiàn)調(diào)用了。
本文題目:vb.net傳入?yún)?shù) vbnet fileopen參數(shù)
文章源于:http://jinyejixie.com/article26/dohhgjg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、網(wǎng)站制作、移動(dòng)網(wǎng)站建設(shè)、云服務(wù)器、小程序開(kāi)發(fā)、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
全網(wǎng)營(yíng)銷(xiāo)推廣知識(shí)