M函数文件代码:
function flowtype1(k,j,g,o,t,h)
q=0.001:0.001:10;
dpsg=64/t*100*k*(t/100*q*k/g).^(-1).*q.^2/2;
Y=(j-k)*9.8*sin(o)./dpsg;
p=4.56*h*((j-k)*cos(o)*t^0.8*q.^0.4/j).^0.5;
plot(q,p)
hold on
p=(((Y+63.8)/(1+1.5*(j/k)^(1/3))).^0.5+2.86).*q/8.59;
plot(q,p,'r')
在转换dll时,CLASS为flowtype。
在VB中,有6个Text控件和一个按钮,代码如下:
Private z As Double
Private x As Double
Private m As Double
Private ha As Double
Private c As Double
Private b As Double
Private theflowtype1 As flowtype1.flowtype
Private Sub Command1_Click()
Dim y As Variant
If theflowtype1 Is Nothing Then Exit Sub
On Error GoTo Handle_Error
Call theflowtype1.flowtype(k, j, g, o, t, h)
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub Form_Load()
Set theflowtype1 = New flowtype1.flowtype
k = 0.8
j = 1
g = 0.0001
o = 0.5
t = 25
h = 0.5
Exit Sub
Handle_Error:
MsgBox (Err.Description)
End Sub
Private Sub Text1_Change()
'This function is called when ever the contents of the
'Text box change. Sets the current value of Size.
On Error Resume Next
k = CDbl(Text1.Text)
If Err <> 0 Then
k = 0.8
End If
End Sub
Private Sub Text2_Change()
On Error Resume Next
j = CDbl(Text2.Text)
If Err <> 0 Then
j = 1
End If
End Sub
Private Sub Text3_Change()
On Error Resume Next
g = CDbl(Text3.Text)
If Err <> 0 Then
g = 0.0001
End If
End Sub
Private Sub Text4_Change()
On Error Resume Next
o = CDbl(Text4.Text / 180 * pi)
If Err <> 0 Then
o = 0.5
End If
End Sub
Private Sub Text5_Change()
On Error Resume Next
t = CDbl(Text5.Text)
If Err <> 0 Then
t = 25
End If
End Sub
Private Sub Text6_Change()
On Error Resume Next
h = CDbl(Text6.Text)
If Err <> 0 Then
h = 0.5
End If
End Sub
在VB中引用dl后运行,出现对象不支持该属性和方法的提示,请教大牛哪里出错了,谢谢大家。