1.新建工程ActiveX.dll.
2.从命名工程名和类名,并编写类方法,后保存成DLL
3.用regsvr32 + DLL的全路径.(注册)
4.打开VBS 定义该DLL对象.
"Set test = CreateObject("test.class")"(test是工程名,class是类名)
5.用对象点方法就可以了.
例VB里输入代码:
Public Function getData() As String
Dim head As Long
Dim short As Integer
Open "c:\relate.hk" For Binary As #1
Get #1,head
'Do While Not EOF(1)
'Loop
Close #1
usSerial = Replace(Trim(usSerial)," ","|")
usCount = Replace(Trim(usCount),"|")
toSerial = Replace(Trim(toSerial),"|")
getData = usSerial & "~" & usCount & "~" & toSerial
End Function
保存为DLL,工程名为:test,类名为class
Dim test Set test = CreateObject("test.class") 'getstr=Split(test.getData,"~") Debug.WriteLine test.getData
原文链接:https://www.f2er.com/vb/259019.html