加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

vb 生成dll ,vbs 调用dll

发布时间:2020-12-17 08:16:50 所属栏目:百科 来源:网络整理
导读:1.新建工程ActiveX. dll . 2.从命名工程名和类名,并编写类方法,后保存成 DLL 3.用regsvr32 + DLL 的全路径.(注册) 4.打开 VBS 定义该 DLL 对象. "Set test = CreateObject("test.class")"(test是工程名,class是类名) 5.用对象点方法就可以了. 例VB里输入代码

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读