关于VB.NET中-引用类型参数传递的问题
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的值而复制的一个变量。
vb.net 调用C语言可执行程序并传值?
在c语言中每一个变量都有两个属性一个是值,一个是址。比如inta=2;变量a的值是2,变量a的地址,可以用取地址
操作符
获取,即a。因此以C语言的函数传递中具备两种方式传递参数,一种是传址,一种传值。比如voidf1(intv){;}//函数f1v
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跨语言传参的词条
链接地址:http://scyingshan.cn/article/hshoej.html