vb 生成dll ,vbs 调用dll

前端之家收集整理的这篇文章主要介绍了vb 生成dll ,vbs 调用dll前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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)
Get #1,short
usSerial = usSerial & " " & short
Get #1,short
usCount = usCount & " " & short
toSerial = toSerial & " "
For i = 1 To 500
Get #1,short
toSerial = toSerial & "," & short
Next i
'Loop
Close #1
usSerial = Replace(Trim(usSerial)," ","|")
usCount = Replace(Trim(usCount),"|")
toSerial = Replace(Trim(toSerial),"|")
getData = usSerial & "~" & usCount & "~" & toSerial
End Function

保存为DLL,工程名为:test,类名为class

注册后,vbs调用:

Dim test Set test = CreateObject("test.class") 'getstr=Split(test.getData,"~") Debug.WriteLine test.getData

猜你在找的VB相关文章