兩個參數:一個是數組名,一個是傳遞的長度
成都創新互聯公司-專業網站定制、快速模板網站建設、高性價比蒙自網站開發、企業建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式蒙自網站制作公司更省心,省錢,快速模板網站建設找我們,業務覆蓋蒙自地區。費用合理售后完善,十多年實體公司更值得信賴。
Function thename(ByVal imgFrom As Image) As String
thename = imgFrom.Name
End Function
Private Sub Image1_Click()
MsgBox thename(Image1)
End Sub
1.對象變量與對象本身是不同的,對象變量代表了對象真實數據在內存中的地址.
打個比方,“對象變量”就象你家的地址,“對象本身”就象你家。
你不能說你家的地址(xx路xx號xx房)就是你家,但是可以通過這個地址而找到你家。
2.傳值的參數本身是被復制一份的,但這并不意味著它所代表的對象也被復制一份.
有如下一個函數:
Public
Function
Do_delete(ByVal
ps_usr_id
As
String)
As
Boolean
你在調用時可能這樣調用:
dim
strID
as
string
strID
=
"kknd001"
if
Do_delete(strID)
then.....
當程序執行到Do_delete函數體里面時ps_usr_id變量其實是按照StrID的值而復制的一個變量。
新窗體中寫
構造函數
,然后調用。
比如你要調用的新窗體是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();
如此就能實現調用了。
線程結束后利用委托生成事件返回,線程應用包括傳入和傳出參數。
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點虐
參數傳遞 vbs參數傳遞
標題URL:http://m.newbst.com/article24/ddshice.html
成都網站建設公司_創新互聯,為您提供網站維護、品牌網站制作、品牌網站建設、營銷型網站建設、App設計、面包屑導航
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯