sheila1978
asked on
Modify VB database with C++ dll. How?
I created a dll (in c++) to modify a 2D array and return the modified 2D array. I have a database in VB with 200 records of 5 fields each. I want to use my dll to return certains fields into my VB application.
The dll function: int _stdcall pusingan1(float now1[200][5])
it returns: dahPasang[200][5];
dahPasang is declared as float
the .def file exports: pusingan1;
The dll file is successfully built:
pusingan1.dll - 0 error(s), 32 warning(s)
there are only 2 types of warnings ..
warning C4101: 'pasang1' : unreferenced local variable
warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
the unreferenced local variables are for future use; the float -> integer conversion is for calculation purpose
In VB I use 2 forms : Form1 for the database & Form2 to display the required fields
I have declared the dll in both forms:
Private Declare Function pusingan1 Lib "C:\My Documents\vbPsm\pusingan1\ Debug\pusi ngan1.dll" () As Variant
Then I want to give a variable name for my database using these steps:
Private Sub Command3_Click()
now1 = Data1.Recordset
Form1.Hide
Form2.Show
End Sub
In Form2 I want to call the dll to modify my database but I'm not very familiar with VB.
If I use pusingan1(now1) .. error .. This program has performed an illegal operation
If I use now1.pusingan1 .. error .. run-time error '424': object required
************************** ********** ********** ********** ********** **********
Q1 : Please tell me how to send my database to the dll.
************************** ********** ********** ********** ********** **********
Then, I tried to just display a specific field from the database in the previous form using the command below:
Private Sub Command1_Click()
Dim arrayKu As Variant
Dim num1 As Integer
arrayKu = now1
num1 = arrayKu(0, 0)
Text1.Text = num1
End Sub
The result when I press Command1 is:
run-time error '13': Type mismatch at num1 = arrayKu(0,0)
************************** ********** ********** ********** ********** **********
Q2 : Please tell me how to retrieve the field I want into a text box.
************************** ********** ********** ********** ********** **********
The dll function: int _stdcall pusingan1(float now1[200][5])
it returns: dahPasang[200][5];
dahPasang is declared as float
the .def file exports: pusingan1;
The dll file is successfully built:
pusingan1.dll - 0 error(s), 32 warning(s)
there are only 2 types of warnings ..
warning C4101: 'pasang1' : unreferenced local variable
warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
the unreferenced local variables are for future use; the float -> integer conversion is for calculation purpose
In VB I use 2 forms : Form1 for the database & Form2 to display the required fields
I have declared the dll in both forms:
Private Declare Function pusingan1 Lib "C:\My Documents\vbPsm\pusingan1\
Then I want to give a variable name for my database using these steps:
Private Sub Command3_Click()
now1 = Data1.Recordset
Form1.Hide
Form2.Show
End Sub
In Form2 I want to call the dll to modify my database but I'm not very familiar with VB.
If I use pusingan1(now1) .. error .. This program has performed an illegal operation
If I use now1.pusingan1 .. error .. run-time error '424': object required
**************************
Q1 : Please tell me how to send my database to the dll.
**************************
Then, I tried to just display a specific field from the database in the previous form using the command below:
Private Sub Command1_Click()
Dim arrayKu As Variant
Dim num1 As Integer
arrayKu = now1
num1 = arrayKu(0, 0)
Text1.Text = num1
End Sub
The result when I press Command1 is:
run-time error '13': Type mismatch at num1 = arrayKu(0,0)
**************************
Q2 : Please tell me how to retrieve the field I want into a text box.
**************************
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.