谁能教教我VB6怎么编写DLL,并且调用运行

如题所述

在vb中制作dll文件及在vb程序中引用此文件

一、在vb中制作dll文件
(1)新建一个Active DLL工程,名字为vbTestdll,类模块的名字为testdll
(2)在类模块中实现一个函数,内容如下:
Public Function mydll() As String
mydll = "Hello World";
End Function
(3)保存,然后在文件菜单中选择 Make vbtestdll.dll项,生成dll文件
二、在vb程序中使用此dll文件
(1)新建一个标准工程。
(2)在工程-引用-浏览里找到vbtestdll.dll文件,并且把它引入
(3)写测试代码,内容如下
Option Explicit
Dim test As testdll'类模块名字

Private Sub Form_Load()
Set test= New testdll 'DLL的一个新实例
Me.Caption = test.mydll '我的标题=返回DLL的Hello World
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-10-26
用vc建立一个dll工程XXX,选择3个模板。
.cpp代码
long __stdcall fun(long a,long b){}
.h代码
long __stdcall fun(long a,long b);
.def
LIBRARY XXX
EXPLORT
fun @1
编译
相似回答