多重循环
for a=1 to 10
  for b=1 to 10
    for c=1 to 10
    next c
  next b
next a怎样当c=5(任意值,或者说任意条件)的时候, a的值加1?

解决方案 »

  1.   

    for a=1 to 10
      for b=1 to 10
        for c=1 to 10
         if c=5 then a=a+1
        next c
      next b
    next a我觉得你没有问明白,这样做没啥意义
      

  2.   

    是没问明白..
    Private Sub Command1_Click()
    Dim a As Long
    Dim b As Long
    Dim c As Long
    Dim d As Long
    Dim z As Long
    Dim sa As String
    Dim sb As String
    Dim sc As String
    Dim sd As String
    Dim sz As String
    Dim str As String
    Dim count As Long
    Dim sCount As String
    Dim n As Integer
    count = 1
    n = 1For z = 201 To 500
        For a = 20 To 100
            For b = 20 To 100
                    For c = 20 To 100
                            For d = 20 To 100
                                    
                                            If a * c * z = 120 * b * d Then
                                                    If ((a <> b) And (a <> c) And (a <> d) And (b <> c) And (b <> d) And (c <> d)) And ((a + b) * 3.5 >= 240) Then
                                                        sa = a
                                                        sb = b
                                                        sc = c
                                                        sd = d
                                                        sz = z
                                                        sCount = count
                                                        str = sCount + "  :" + " a:" + sa + " b:" + sb + " c:" + sc + " d:" + sd + " z:" + sz
                                                        count = count + 1
                                                        List1.AddItem (str)
                                                    
                                                        If count = 30 Then
                                                        Exit Sub
                                                        End If
                                                    End If
                                            End If
                                Next d
                        Next c
                Next b
        Next a
    Next zEnd Sub
    这是源码,就是想实现列出1行数之后,能从Z的值加1再开始算.Z的值每变一位只打出1行结果就可以.