读书人

ActiveX DLL有关问题求教~

发布时间: 2012-01-31 21:28:41 作者: rapoo

ActiveX DLL问题求教~~~
新建一个 ActiveX DLL 类模块(cls.cls)里面代码:
Option Explicit
Public Function GreetDaw(ByVal s_name As String) As String
Dim frm As Form

Set frm = New Form1
Load frm
frm.Show
GreetDaw = "稀里哗啦 " & s_name & "完成! "
End Function

在这个ActiveX DLL添加一个窗体Form1,窗体上加一个Text1。

生成SamplePLUGIN.dll



然后新建一个标准 EXE,引用这个Dll,窗体代码:
Dim SamP As Object

Private Sub Form_Load()
Set SamP = CreateObject("SamplePLUGIN.cls")
End Sub

Private Sub Command1_Click()
MsgBox SamPLUGIN.GreetDaw(Text1.Text)
End Sub

在text1输入“123”,单击Command1就出现 “稀里哗啦 123完成!” 的msgbox窗体,和Dll的窗体

如何使那个Dll里面的Text1内容为 这个标准EXE的Text1内容呢?

[解决办法]
ActiveX DLL如下:

VB code
'Form1窗体Option ExplicitPrivate Sub Form_Load()        Me.Visible = False        Me.Text1.Text = "chenjl1031"End Sub'类模块Option ExplicitPublic Function GreetDaw(ByVal BForm As Boolean, ByVal SetTextBoxValue As String) As String  Form1.Visible = BForm  Form1.Text1.Text = SetTextBoxValue  GreetDaw = "稀里哗啦 " & SetTextBoxValue & "完成! "End Function 

读书人网 >VB

热点推荐