咨询关于vb调用含有结构体dll(vc++开发,带有多输出函数值)问题
大家好!看了很多本论坛上的帖子,很受启发,但是关于vb调用含有多输出函数值vcdll的问题很少涉及,我在编程过程中遇到了该方面问题,解决不了,希望得到大家指点,谢谢!vc...
大家好!
看了很多本论坛上的帖子,很受启发,但是关于vb调用含有多输出函数值vc dll的问题很少涉及,我在编程过程中遇到了该方面问题,解决不了,希望得到大家指点,谢谢!
vc中cpp文件为:
struct res
{
double r;
double Wc;
double Wr;
};
struct res lo(double uo,double dw,double dm)
{
struct res result;
double r,Wc,Wr;
result.r =uo;
result.Wc=dw;
result.Wr=dm;
return result;
}
vb中代码:
Private Type js
x As Double
y As Double
z As Double
End Type
Private Declare Function lo Lib "sample1.dll" (ByVal uo As Double, ByVal dw As Double, ByVal dm As Double) As Double
Private Sub Command1_Click()
Dim n(3) As Double
n(3) = lo(CDbl(Text1.Text), CDbl(Text2.Text), CDbl(Text3.Text))
Text5.Text = n(0)
Text6.Text = n(1)
Text7.Text = n(2)
End Sub
其中函数为三输入三输出形式的,想实现的是将vb中三个TextBox 控件中输入的值传给vc开发的dll,通过调用lo函数返回三个结果值,谢谢! 展开
看了很多本论坛上的帖子,很受启发,但是关于vb调用含有多输出函数值vc dll的问题很少涉及,我在编程过程中遇到了该方面问题,解决不了,希望得到大家指点,谢谢!
vc中cpp文件为:
struct res
{
double r;
double Wc;
double Wr;
};
struct res lo(double uo,double dw,double dm)
{
struct res result;
double r,Wc,Wr;
result.r =uo;
result.Wc=dw;
result.Wr=dm;
return result;
}
vb中代码:
Private Type js
x As Double
y As Double
z As Double
End Type
Private Declare Function lo Lib "sample1.dll" (ByVal uo As Double, ByVal dw As Double, ByVal dm As Double) As Double
Private Sub Command1_Click()
Dim n(3) As Double
n(3) = lo(CDbl(Text1.Text), CDbl(Text2.Text), CDbl(Text3.Text))
Text5.Text = n(0)
Text6.Text = n(1)
Text7.Text = n(2)
End Sub
其中函数为三输入三输出形式的,想实现的是将vb中三个TextBox 控件中输入的值传给vc开发的dll,通过调用lo函数返回三个结果值,谢谢! 展开
展开全部
这个吗,很简单的,用数组解决就可以:
vc的sample.cpp
int __stdcall fun(double a, double b, double * res)
{
res[0] = a + b;
res[1] = a - b;
res[2] = a * b;
res[3] = a / b;
return 0;
}
vc的sample.def
EXPORTS
fun
vb:
declare sub fun lib "sample.dll" (byval a as double, byval b as double, byref x as double)
private sub command1_click()
dim x(4) as double
fun 1,2,x(0)
text1.text = x(0)
text2.text = x(1)
text3.text = x(2)
text4.text = x(3)
end sub
在上面的例子里,把数组第一个元素传递给dll就可以作为返回值把东西带回来了
vc的sample.cpp
int __stdcall fun(double a, double b, double * res)
{
res[0] = a + b;
res[1] = a - b;
res[2] = a * b;
res[3] = a / b;
return 0;
}
vc的sample.def
EXPORTS
fun
vb:
declare sub fun lib "sample.dll" (byval a as double, byval b as double, byref x as double)
private sub command1_click()
dim x(4) as double
fun 1,2,x(0)
text1.text = x(0)
text2.text = x(1)
text3.text = x(2)
text4.text = x(3)
end sub
在上面的例子里,把数组第一个元素传递给dll就可以作为返回值把东西带回来了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询