系统提示我"实时错误11:除数为零"
但怎么可能呢? Suc = (Num * (ECol - BCol + 1) - N) / (Num * (ECol - BCol + 1)) * 100
其中:Num= 2;Ecol = 13;Bcol = 2;N = 24
但怎么可能呢? Suc = (Num * (ECol - BCol + 1) - N) / (Num * (ECol - BCol + 1)) * 100
其中:Num= 2;Ecol = 13;Bcol = 2;N = 24
Num = 2: Ecol = 13: Bcol = 2: N = 24
Suc = (Num * (Ecol - Bcol + 1) - N) / (Num * (Ecol - Bcol + 1)) * 100
MsgBox Suc
End Sub
分子是0,分母是2400,商为0.除数为零不存在,不是这里的问题
dim const Num as integer = 2
dim const Ecol as integer = 13
dim const Bcol as integer = 2
dim const N as integer = 24
'根据需要将常量定义改为输入值
'function sub myDiv (byval Num as integer,Ecol as integer,Bcol as integer,N as integer) as string
dim Result as integer
on error goto errDiv
myDiv = ''
Result = (Num * (Ecol - Bcol + 1) - N) / (Num * (Ecol - Bcol + 1)) * 100
exit sub
errDiv:
myDiv = Err.Description
end subPrivate Sub Command1_Click() '显示
msgbox myDiv
end sub
1.Private Sub HisFty_Click()
Num = 2
I1 = 1 'I1,Num用于历史数据期数的大循环
I2 = 8 'I2,Pst用于开奖数据的位置循环
Pst = 8
Combo1.Text = "双色球兰球分析" '以此确定打开的文件对象
Call HisDInput(Combo1.Text, I1, I2, Num, Pst)2.Public Sub HisDInput(Colball As String, ByVal I1, I2, Num, Pst)
Dim BRow, ERow, BCol, ECol As Integer
....... BRow = 2
ERow = 1 + Num
BCol = 2
ECol = 13
Call 成功率(LottoryBook.Worksheets(ASheet), BRow, ERow, BCol, ECol)
3.Public Sub 成功率(ByVal LottorySheet As Excel.Worksheet, BRow, ERow, BCol, ECol)
Dim Suc As Integer
LottorySheet.Select
N = 0
For J = BRow To ERow
For K = BCol To ECol
If LottorySheet.Cells(J, K) = "" Then '如果单元格不为空,不计入总数
N = N + 1 '统计共有数据的个数
End If
Next K
Next J
Suc = (Num * (ECol - BCol + 1) - N) / (Num * (ECol - BCol + 1)) * 100
Debug.Print "suc:"; Suc
LottorySheet.Cells(1, 14) = Suc
Private Sub Command1_Click()
Dim suc As Integer, ecol As Integer, bcol As Integer, n As Integer
Num = 2: ecol = 13: bcol = 2: n = 24
suc = (Num * (ecol - bcol + 1) - n) / (Num * (ecol - bcol + 1)) * 100
Print suc
End Sub
2 你可以在立即窗口中输入
?[表达式]
然后回车,可以看到表达式的值
3 你可以将需要观察的部分元素选定,然后让鼠标在上边等一会儿,可以看到组合元素的值.
4 你可以在选中部分元素后使用Shift+F9,添加监视,在监视窗口中观察变量值的变化
5 你可以显示本地窗口,直接查看本地元素的值