成都创新互联网站制作重庆分公司

vb.net传入参数 vbnet fileopen参数

vb.net 如何传递类参数

线程结束后利用委托生成事件返回,线程应用包括传入和传出参数。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册网站空间、营销软件、网站建设、铜川网站维护、网站推广。

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 = "测试"

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

vb.net 给委托的函数传递参数

两个参数:一个是数组名,一个是传递的长度

Function thename(ByVal imgFrom As Image) As String

thename = imgFrom.Name

End Function

Private Sub Image1_Click()

MsgBox thename(Image1)

End Sub

VB.net 两个窗体之间传递参数

新窗体中写

构造函数

,然后调用。

比如你要调用的新窗体是From1.cs这个窗体,

public

Form1(要传入的参数)

{

//把传入的参数传入窗体中

//执行窗体标准内容

}

然后在需要调用的地方调用

Form1

f

=

new

Form1(传出的参数);

'--------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();

如此就能实现调用了。


网站题目:vb.net传入参数 vbnet fileopen参数
当前链接:http://cxhlcq.com/article/dohhgjg.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部