vb程序中缺少子程序,函数或属性,怎么办? 5
PrivateSubCommand1_Click()DimIAsInteger,M0AsSingle,TextLienAsString,X()AsSingle,Y()As...
Private Sub Command1_Click()
Dim I As Integer, M0 As Single, TextLien As String, X() As Single, Y() As Single
CommonDialog1.Filter = "Metafile (*.*)|*.*"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Text1.Text = CommonDialog1.FileName
M0 = 0: f0 = 0: Fn = 0
Do Until EOF(1)
Line Input #1, TextLien: M0 = M0 + 1
Loop
Seek #1, 1
ReDim X(M0), Y(M0)
For I = 1 To M0
Input #1, X(I), Y(I)
Next I
Close 1
End Sub
Private Sub Command2_Click()
Dim YiYuanHuiGui As Integer
Dim B0 As Single, B1 As Single, r As Single
Call YiYuanHuiGui
Text2.Text = B0
Text3.Text = B1
Text4.Text = r
End Sub
Function YiYuanHuiGui(AX, AY, n, Y0, B0, B1, r) As Integer
Dim I As Integer, J As Integer
Dim SX As Single, SY As Single, EX As Single, EY As Single
Dim Lxx As Single, Lyy As Single, Lxy As Single
C = 0: d = 0
For I = 1 To n
SX = SX + AX(I): SY = SY + AY(I)
Next
EX = SX / n: EY = SY / n
Lxx = 0: Lyy = 0: Lxy = 0
For I = 1 To n
Lxx = Lxx + (AX(I) - EX) ^ 2
Lyy = Lyy + (AY(I) - EY) ^ 2
Lxy = Lxy + (AX(I) - EX) * (AY(I) - EY)
Next
B1 = Lxy / Lxx: B0 = EY - B1 * EX
r = Lxy / (Lxx * Lyy) ^ 0.5
End Function
问题定位在Call YiYuanHuiGui
已经请高手帮忙解决了,谢谢各位了。
新手提问都不是很明确,以后会注意,会努力学习的 展开
Dim I As Integer, M0 As Single, TextLien As String, X() As Single, Y() As Single
CommonDialog1.Filter = "Metafile (*.*)|*.*"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Text1.Text = CommonDialog1.FileName
M0 = 0: f0 = 0: Fn = 0
Do Until EOF(1)
Line Input #1, TextLien: M0 = M0 + 1
Loop
Seek #1, 1
ReDim X(M0), Y(M0)
For I = 1 To M0
Input #1, X(I), Y(I)
Next I
Close 1
End Sub
Private Sub Command2_Click()
Dim YiYuanHuiGui As Integer
Dim B0 As Single, B1 As Single, r As Single
Call YiYuanHuiGui
Text2.Text = B0
Text3.Text = B1
Text4.Text = r
End Sub
Function YiYuanHuiGui(AX, AY, n, Y0, B0, B1, r) As Integer
Dim I As Integer, J As Integer
Dim SX As Single, SY As Single, EX As Single, EY As Single
Dim Lxx As Single, Lyy As Single, Lxy As Single
C = 0: d = 0
For I = 1 To n
SX = SX + AX(I): SY = SY + AY(I)
Next
EX = SX / n: EY = SY / n
Lxx = 0: Lyy = 0: Lxy = 0
For I = 1 To n
Lxx = Lxx + (AX(I) - EX) ^ 2
Lyy = Lyy + (AY(I) - EY) ^ 2
Lxy = Lxy + (AX(I) - EX) * (AY(I) - EY)
Next
B1 = Lxy / Lxx: B0 = EY - B1 * EX
r = Lxy / (Lxx * Lyy) ^ 0.5
End Function
问题定位在Call YiYuanHuiGui
已经请高手帮忙解决了,谢谢各位了。
新手提问都不是很明确,以后会注意,会努力学习的 展开
展开全部
Private Sub Command2_Click()
Dim YiYuanHuiGui As Integer
Dim B0 As Single, B1 As Single, r As Single
Call YiYuanHuiGui
Text2.Text = B0
Text3.Text = B1
Text4.Text = r
End Sub
call YiYuanHuiGui '是调用自定义过程"YiYuanHuiGui"的意思,
所以不有和自定义的整形变量Dim YiYuanHuiGui As Integer 同名,
至于:
Text2.Text = B0
Text3.Text = B1
Text4.Text = r
如果想把文本框的内容赋值给那三个变量的话,应该写成:
BO=text2.text
B1=text3.text
r=text4.text
否则返回的是空字符串...
Dim YiYuanHuiGui As Integer
Dim B0 As Single, B1 As Single, r As Single
Call YiYuanHuiGui
Text2.Text = B0
Text3.Text = B1
Text4.Text = r
End Sub
call YiYuanHuiGui '是调用自定义过程"YiYuanHuiGui"的意思,
所以不有和自定义的整形变量Dim YiYuanHuiGui As Integer 同名,
至于:
Text2.Text = B0
Text3.Text = B1
Text4.Text = r
如果想把文本框的内容赋值给那三个变量的话,应该写成:
BO=text2.text
B1=text3.text
r=text4.text
否则返回的是空字符串...
展开全部
删掉Private Sub Command2_Click() 中的 Dim YiYuanHuiGui As Integer 他与函数同名
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
错误定位在哪行?这样看代码很晕的。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询