| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2138 人关注过本帖
标题:新手自编一个双色球筛选程序,求助大神帮忙看一下代码问题
只看楼主 加入收藏
TMAKER
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-5-24
收藏
 问题点数:0 回复次数:1 
新手自编一个双色球筛选程序,求助大神帮忙看一下代码问题
Private Sub Command1_Click()
Dim a() As String '定义传值a数组
Dim a2() As String '定义传值a2数组
Dim a3() As String '定义传值a3数组
Dim a4() As String '定义传值a4数组
Dim a5() As String '定义传值a5数组
Dim a6() As String '定义传值a6数组
Dim a7() As String '定义传值a7数组
Dim a8() As String '定义传值a8数组
Dim a9() As String '定义传值a9数组
Dim a10() As String '定义传值a10数组
Dim a11() As String '定义传值a11数组
Dim i, j, t, n As Integer '定义循环变量
Dim X(1 To 6) As String, y As Integer '定义一个6维数组存储下标及循环变量
Dim M1%, M2%, M3%, M4%, M5%, M6%
Dim n2, n3, n4, n5, n6, n7, n8, n9, n10, n11 As Integer '定义计数变量
Dim k2, k3, k4, k5, k6, k7, k8, k9, k10, k11 As Integer '定义筛选循环变量
Dim num(1 To 6) As Long '定义一个数组接收符合条件的数组
    Text12 = ""
    a = Split(Text1.Text, " ") '存入a数组
    a2 = Split(Text2.Text, " ") '存入a2数组
    a3 = Split(Text3.Text, " ") '存入a3数组
    a4 = Split(Text4.Text, " ") '存入a4数组
    a5 = Split(Text5.Text, " ") '存入a5数组
    a6 = Split(Text6.Text, " ") '存入a6数组
    a7 = Split(Text7.Text, " ") '存入a7数组
    a8 = Split(Text8.Text, " ") '存入a8数组
    a9 = Split(Text9.Text, " ") '存入a9数组
    a10 = Split(Text10.Text, " ") '存入a10数组
    a11 = Split(Text11.Text, " ") '存入a11数组
    Randomize '初始化随机数发生器
   
    n2 = 0
   
   
    For i = 1 To UBound(a) - 1
      For j = i + 1 To UBound(a)
        If Val(a(i)) > Val(a(j)) Then t = a(i): a(i) = a(j): a(j) = t 'a数组大小排序
      Next
    Next
   
    For M1 = 0 To UBound(a) - 5
      num(1) = a(M1) '遍历数组a的第一个数赋值给数组num
      For j = 0 To UBound(a2) '内循环控制数组a2
        If Val(num(1)) = Val(a2(j)) Then n2 = n2 + 1 '如果每有一个数相同,则n2+1
      Next j
      For M2 = M1 + 1 To UBound(a) - 4
        num(2) = a(M2) '遍历数组a的第二个数赋值给数组num
        For j = 0 To UBound(a2) '内循环控制数组a2
          If Val(num(2)) = Val(a2(j)) Then n2 = n2 + 1 '如果每有一个数相同,则n2+1
        Next j
        For M3 = M2 + 1 To UBound(a) - 3
          num(3) = a(M3) '遍历数组a的第三个数赋值给数组num
          For j = 0 To UBound(a2) '内循环控制数组a2
            If Val(num(3)) = Val(a2(j)) Then n2 = n2 + 1 '如果每有一个数相同,则n2+1
          Next j
          For M4 = M3 + 1 To UBound(a) - 2
            num(4) = a(M4) '遍历数组a的第四个数赋值给数组num
            For j = 0 To UBound(a2) '内循环控制数组a2
              If Val(num(4)) = Val(a2(j)) Then n2 = n2 + 1 '如果每有一个数相同,则n2+1
            Next j
            For M5 = M4 + 1 To UBound(a) - 1
              num(5) = a(M5) '遍历数组a的第五个数赋值给数组num
              For j = 0 To UBound(a2) '内循环控制数组a2
                If Val(num(5)) = Val(a2(j)) Then n2 = n2 + 1 '如果每有一个数相同,则n2+1
              Next j
              For M6 = M5 + 1 To UBound(a)
                  num(6) = a(M6) '遍历数组a的第六个数赋值给数组num
                  For j = 0 To UBound(a2) '内循环控制数组a2
                    If Val(num(6)) = Val(a2(j)) Then n2 = n2 + 1 '如果每有一个数相同,则n2+1
                  Next j
                    
                  If n2 = 0 Then '如果条件为空,则直接输出结果
                      For i = 1 To 6
                          Text12 = Text12 & num(i) & " "
                      Next i
                      Text12 = Text12 & vbCrLf
                      DoEvents
                  Else '如果条件不为空
                  
                    If Val(Combo1.Text) = Val(Combo2.Text) Then '情况一
                      If n2 = Val(Combo1.Text) Or n2 = Val(Combo2.Text) Then '如果符合条件,则输出结果
                          For i = 1 To 6
                              Text12 = Text12 & num(i) & " "
                          Next i
                          n2 = 0
                          Text12 = Text12 & vbCrLf
                          DoEvents
                      Else '如果不符合条件,则不输出结果
                          Text12 = Text12
                          n2 = 0
                      End If
                    ElseIf Val(Combo1.Text) < Val(Combo2.Text) Then '情况二
                      If Val(Combo1.Text) <= n2 <= Val(Combo2.Text) Then  '如果符合条件,则输出结果
                          For i = 1 To 6
                              Text12 = Text12 & num(i) & " "
                          Next i
                          n2 = 0
                          Text12 = Text12 & vbCrLf
                          DoEvents
                      Else '如果不符合条件,则不输出结果
                          Text12 = Text12
                          n2 = 0
                      End If
                    ElseIf Val(Combo1.Text) > Val(Combo2.Text) Then '情况三
                      If Val(Combo1.Text) >= n2 >= Val(Combo2.Text) Then  '如果符合条件,则输出结果
                          For i = 1 To 6
                              Text12 = Text12 & num(i) & " "
                          Next i
                          n2 = 0
                          Text12 = Text12 & vbCrLf
                          DoEvents
                      Else '如果不符合条件,则不输出结果
                          Text12 = Text12
                          n2 = 0
                      End If
                    End If
                  End If
                 
              Next
            Next
          Next
        Next
      Next
    Next
   
End Sub

Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
Text7 = ""
Text8 = ""
Text9 = ""
Text10 = ""
Text11 = ""
Text12 = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
Combo4.Text = ""
Combo5.Text = ""
Combo6.Text = ""
Combo7.Text = ""
Combo8.Text = ""
Combo9.Text = ""
Combo10.Text = ""
Combo11.Text = ""
Combo12.Text = ""
Combo13.Text = ""
Combo14.Text = ""
Combo15.Text = ""
Combo16.Text = ""
Combo17.Text = ""
Combo18.Text = ""
Combo19.Text = ""
Combo20.Text = ""


End Sub




个人发现现在的问题是n2在循环后如何归零,如果有其它问题请帮忙指正
搜索更多相关主题的帖子: 数组 num Text For Next 
2018-05-24 22:49
TMAKER
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-5-24
收藏
得分:0 
顶起。。。。
2018-05-25 18:42
快速回复:新手自编一个双色球筛选程序,求助大神帮忙看一下代码问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052522 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved