|
-
April 16th, 2001, 11:20 AM
#1
call a .DLL in a VB form
i created a .DLL named (dlldemo.dll) using MS visual C++
below is my DLL function in C++.
#include <windows.h>
void __stdcall Multiply(int Cheight, int Cwidth, int Cproduct)
{
Cproduct = Cheight * Cwidth;
return;
}
well, what my DLL does is that it computes the Cproduct from input Cheight and Cwidth of a form.
below in my VB form that calls the .DLL
option Explicit
private Declare Sub Multiply Lib "C:\dlldemo.dll" (Cheight as Integer, Cwidth as Integer, Cproduct as Integer)
'-------------------------------------------------------------------
'In my form, upon OK button is clicked....
private Sub CmdOk_Click()
Dim Cheight as Integer, Cwidth as Integer, Cproduct as Integer
Cheight = Val(txtHeight.Text) 'input height from textbox
Cwidth = Val(txtWidth.Text) 'input width from textbox
Multiply Cheight, Cwidth, Cproduct ' call DLL
If Cproduct Mod 2 <> 0 then 'return(Cproduct) the computed value in .DLL to here...
'POP up a msgbox if the computed Cproduct is an odd num...
MsgBox "The values generate an odd number of icons." & vbCrLf & _
"Change Width and/or Height so that their product " & vbCrLf & _
"is an even number.", vbInformation, "Change Width and/or Height"
Exit Sub
:
:
:
well, i my problem is that my msgBox does not pop-up if the Cproduct is an odd number.
i think that something is wrong in my .DLL or maybe the way i call my DLL is incorrect.. anyone noes where is the problem?? pls reply, thank you.
-
April 16th, 2001, 12:04 PM
#2
Re: call a .DLL in a VB form
Try debugging the value of Cproduct. Then it might tell you why Cproduct mod 2 <> 0.
-Cool Bizs
Good Luck,
-Cool Bizs
-
April 16th, 2001, 12:17 PM
#3
Re: call a .DLL in a VB form
hi cool Bizs, u in the same time zone as me?
-
April 16th, 2001, 12:37 PM
#4
Re: call a .DLL in a VB form
Try this.
#include <windows.h>
LONG __stdcall Multiply(int Cheight, int Cwidth)
{
INT CProduct;
Cproduct = Cheight * Cwidth;
return CProduct;
}
Then in the VB Program
option Explicit
private Declare Sub Multiply Lib "C:\dlldemo.dll" (byval Cheight as Integer, byval Cwidth as Integer) as long
'-------------------------------------------------------------------
'In my form, upon OK button is clicked....
private Sub CmdOk_Click()
Dim Cheight as Integer, Cwidth as Integer, Cproduct as Long
Cheight = Val(txtHeight.Text) 'input height from textbox
Cwidth = Val(txtWidth.Text) 'input width from textbox
cProduct = Multiply(Cheight, Cwidth) ' call DLL
If Cproduct Mod 2 <> 0 then 'return(Cproduct) the computed value in .DLL to here...
'POP up a msgbox if the computed Cproduct is an odd num...
MsgBox "The values generate an odd number of icons." & vbCrLf & _ "Change Width and/or Height so that their product " & vbCrLf & _ "is an even number.", vbInformation, "Change Width and/or Height"
Exit Sub
Hope this helps
-
April 17th, 2001, 10:45 AM
#5
Re: call a .DLL in a VB form
Well .. I live in Malaysia (for another 2 weeks) and will be back in Stamford CT USA after that. Where are you from?
-Cool Bizs
Good Luck,
-Cool Bizs
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|