求助此VB代码错误
分析双色球冷热号码排序用的,但总是测试失败,求高手指点。代码如下:'==========================================================
' 冷 热 排 序
'==========================================================
'说明:将每一期的前Pub_QS期号码统计中奖次数(不包扩当期),然后按冷热排序
'==========================================================
CpParam.Add "冷热期数",20,"{10}{15}{20}{25}{30}{35}"'用户设置参数
Function Main
'===============申明或定义变量=============
CpRowCount = CpData.RowCount '开奖期数
CpColCount = CpData.ColCount '开奖号码个数
CpMaxCode = CpData.MaxCode '最大号码
CpMinCode = CpData.MinCode '最小号码
CpCodeCount = CpData.CodeCount '号码数量
Pub_3Av = CpCodeCount / 3'三等分
Pub_QS = CInt(CpParam.Value("冷热期数"))
'=================建表=================
CpAna.AddField "期号",8
CpAna.AddField "开奖号码",20
For i = 1 to CpCodeCount
CpAna.AddField i,6
Next
CpAna.RowCount = CpRowCount+1
CpAna.CreateTable()
'==============算法主体============================
ReDim sum(CpCodeCount)'在Pub_QS期内的开奖次数
ReDim SortCodes(CpCodeCount)'根据sum排序后的开奖号码序列
ReDim Codes(CpColCount)'开奖数据
For row = 0 to CpRowCount
'期号 开奖号码
If (row < CpRowCount) Then
CpAna.Cell(row, "期号") = CpData.Seq(row)
CpAna.Cell(row, "开奖号码") = CpData.CodeStr(row)
For col = 0 to CpColCount-1
Codes(col) = CpData.Code(row,col)
Next
End If
'排序
Sort sum, SortCodes'根据开奖次数排序号码,SortCodes为排序好的号码序列
For i = 0 to CpCodeCount-1
CpAna.Cell(row, 2+i) = SortCodes(i)
cl = CpColor.Blue'不冷不热
If (i+1 < Pub_3Av) Then
cl = CpColor.Green'冷
ElseIf i > CpCodeCount - Pub_3Av Then
cl = CpColor.Red'热
End If
If (row < CpRowCount) Then
For col = 0 to CpColCount-1
If Codes(col) = SortCodes(i) Then'本期中奖号码
cl = CpColor.Fuchsia'本期号码
Exit For
End If
Next
End If
CpAna.Color(row,2+i) = cl
Next
If row >= Pub_QS Then
'减去前Pub_QS期的开奖次数
For col = 0 to CpColCount - 1
i = CpData.Code(row-Pub_QS, col)-CpMinCode
sum(i) = sum(i) - 1
Next
End If
For col = 0 to CpColCount - 1
i = Codes(col)-CpMinCode
sum(i) = sum(i) + 1
Next
Next
End Function
'==============辅助函数============================
'根据开奖次数排序号码,Num为排序好的号码序列
Function Sort(ByVal Sum(), ByRef Num())
CpMaxCode = CpData.MaxCode
CpMinCode = CpData.MinCode
CpCodeCount = CpData.CodeCount'号码个数
ReDim aa(CpCodeCount)
For i = 0 to CpCodeCount-1
n = -1
Min = 99999
For j = 0 to CpCodeCount-1
If aa(j) <> -1 And Sum(j) < Min Then
Min = Sum(j)
n = j
End If
Next
Num(i) = CpMinCode+n
aa(n) = -1
Next
End Function
--------------------编程问答-------------------- 哪儿出错?或把整个工程上传,让大家下下来,调一下,当然不能给分哦
补充:VB , 基础类