VB.NET代码 求帮忙转换成VB 6.0
下面这段代码,求高人帮忙转换成VB6.0的代码,对VB6.0不熟悉。
Imports System.Runtime.InteropServicesVB VB.NET VB6.0
Public Class Form
'该函数有三个参数,注意参数类型
Declare Function ExplicitMsg Lib "StationIO.dll" Alias "ExplicitMsgMultiThread" (<MarshalAs(UnmanagedType.LPTStr)> ByVal _lpData As String, <MarshalAs(UnmanagedType.LPTStr)> ByVal _lpTemplate As String, ByVal lpLast As IntPtr) As IntPtr
'该函数无返回值,定义为Sub
Declare Sub FreeMem Lib "StationIO.dll" Alias "FreeMem" (ByVal lpLast As IntPtr)
Sub ButtonOK_click() Handles ButtonOK.Click
Dim lpRes As IntPtr, strRes As String
'第一次调用时,注意第三个参数为0
lpRes = ExplicitMsg(TextBoxData.Text, TextBoxTemplate.Text, 0)
strRes = Marshal.PtrToStringAuto(lpRes)
'再次调用,第三个参数为上次函数返回的指针
lpRes = ExplicitMsg(TextBoxData.Text, TextBoxTemplate.Text, lpRes)
strRes = Marshal.PtrToStringAuto(lpRes)
MessageBox.Show(strRes)
'调用完成,记得FreeMem释放内存
FreeMem(lpRes)
End Sub
End Class
[解决办法]
这个貌似专门有转换的小软件吧,你搜一个下下来不是更好么?
[解决办法]
这样试试看
Public Class Form
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As long, pSource As long, ByVal ByteLen As Long)
'该函数有三个参数,注意参数类型
Declare Function ExplicitMsg Lib "StationIO.dll" Alias "ExplicitMsgMultiThread" ByVal _lpData As String, ByVal _lpTemplate As String, ByVal lpLast As long) As long
'该函数无返回值,定义为Sub
Declare Sub FreeMem Lib "StationIO.dll" Alias "FreeMem" (ByVal lpLast As long)
Sub ButtonOK_click() Handles ButtonOK.Click
Dim lpRes As long, strRes As String
'第一次调用时,注意第三个参数为0
lpRes = ExplicitMsg(TextBoxData.Text, TextBoxTemplate.Text, 0)
copymemory byval varptr(strRes),byval varptr(lpRes), 4
'再次调用,第三个参数为上次函数返回的指针
lpRes = ExplicitMsg(TextBoxData.Text, TextBoxTemplate.Text, lpRes)
copymemory byval varptr(strRes),byval varptr(lpRes), 4
MessageBox.Show(strRes)
'调用完成,记得FreeMem释放内存
FreeMem(lpRes)
End Sub
End Class