您当前的位置:首页 > 计算机 > 编程开发 > VB

VB编程:传递指针变量

时间:06-05来源:作者:点击数:

VB编程:传递指针变量

1、运行效果

VB编程:传递指针变量-41

2、程序代码

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Dim q As String
Dim p As String

Private Sub Command1_Click()
On Error GoTo 1
    jiaohuan p, q
    Text1.Text = q
    Text2.Text = p
1: End Sub

Private Sub Form_Load()
    q = "abcdel"
    p = "123456"
    Text1.Text = q
    Text2.Text = p
End Sub

Private Function jiaohuan(ByRef str1 As String, ByRef str2 As String)
    Dim p
    CopyMemory ByVal VarPtr(p), ByVal VarPtr(str2), 4
    CopyMemory ByVal VarPtr(str2), ByVal VarPtr(str1), 4
    CopyMemory ByVal VarPtr(str1), ByVal VarPtr(p), 4
End Function

 

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐