主题:[讨论]VB 实时错误11
Sub maxmin(x() As Single, ByVal maxnumber As Single, ByVal minnumber As Single)
'x()待处理的一组数据
'maxnumber 为极大值
'minnumber 为极小值
Dim n1 As Integer, n2 As Integer
Dim i As Integer
n1 = UBound(x)
n2 = LBound(x)
maxnumber = x(n1)
minnumber = x(n2)
For i = n2 + 1 To n1
If x(i) > maxnumber Then
maxnumber = x(i)
ElseIf x(i) < minnumber Then
minnumber = x(i)
End If
Next i
End Sub
这是程序调用模块
Dim maxnumber As Single
Dim minnmuber As Single
Dim leftX As Single, topY As Single
Dim rightX As Single, botomY As Single
Dim n As Integer
n = UBound(x)
maxmin x(), maxnumber, minnumber
leftX = minnumber
rightX = maxnumber
maxmin y(), maxnumber, minnumber
topY = maxnumber
bottomY = minnumber
Dim linelen1 As Single, linelen2 As Single
linelen1 = Abs(rightX - leftX) / 4
linelen2 = Abs(topY - bottomY) / 3
pic.Scale (leftX - linelen1, topY + linelen2)-(rightX + linelen1, bottomY - linelen2)
为什么程序运行到最后一句提示实时错误11,除数为零呢?
'x()待处理的一组数据
'maxnumber 为极大值
'minnumber 为极小值
Dim n1 As Integer, n2 As Integer
Dim i As Integer
n1 = UBound(x)
n2 = LBound(x)
maxnumber = x(n1)
minnumber = x(n2)
For i = n2 + 1 To n1
If x(i) > maxnumber Then
maxnumber = x(i)
ElseIf x(i) < minnumber Then
minnumber = x(i)
End If
Next i
End Sub
这是程序调用模块
Dim maxnumber As Single
Dim minnmuber As Single
Dim leftX As Single, topY As Single
Dim rightX As Single, botomY As Single
Dim n As Integer
n = UBound(x)
maxmin x(), maxnumber, minnumber
leftX = minnumber
rightX = maxnumber
maxmin y(), maxnumber, minnumber
topY = maxnumber
bottomY = minnumber
Dim linelen1 As Single, linelen2 As Single
linelen1 = Abs(rightX - leftX) / 4
linelen2 = Abs(topY - bottomY) / 3
pic.Scale (leftX - linelen1, topY + linelen2)-(rightX + linelen1, bottomY - linelen2)
为什么程序运行到最后一句提示实时错误11,除数为零呢?