永发信息网

求VB中动态数组的讲解

答案:1  悬赏:80  手机版
解决时间 2021-05-03 02:55
  • 提问者网友:杀手的诗
  • 2021-05-02 22:20
If IsNull(RulerRS1.Fields("多章节随机标识")) = False Then
           If RulerRS1.Fields("多章节随机标识") <> "" Then
           If UBound(RndArray) = 0 Then            '将第一个随机标识添加入随机标识数组
              ReDim Preserve RndArray(UBound(RndArray) + 1)
              ReDim RndArray(UBound(RndArray) - 1).RndName(1)
              RndArray(UBound(RndArray) - 1).RndFlag = RulerRS1.Fields("多章节随机标识") '随机标识
              RndArray(UBound(RndArray) - 1).RndName(0) = RulerRS1.Fields("章节名称")  '具有相同随机标识的章节名称数组
              RndArray(UBound(RndArray) - 1).RndNumber = Int(right(RndArray(UBound(RndArray) - 1).RndFlag, 1)) '随机选题题数<10
           Else
              LikeFlag = False
              For K = 0 To UBound(RndArray) - 1
                  If RndArray(K).RndFlag = RulerRS1.Fields("多章节随机标识") Then
                     LikeFlag = True
                     Exit For
                  End If
              Next K
              If LikeFlag = False Then
                 ReDim Preserve RndArray(UBound(RndArray) + 1)
                 ReDim RndArray(UBound(RndArray) - 1).RndName(1)
                 RndArray(UBound(RndArray) - 1).RndFlag = RulerRS1.Fields("多章节随机标识") '随机标识
                 RndArray(UBound(RndArray) - 1).RndName(0) = RulerRS1.Fields("章节名称")  '具有相同随机标识的章节名称数组
                 RndArray(UBound(RndArray) - 1).RndNumber = Int(right(RndArray(UBound(RndArray) - 1).RndFlag, 1)) '随机选题题数<10
              Else                                                                      '具有相同标识的只添加章节名称数组
                 ReDim Preserve RndArray(UBound(RndArray) - 1).RndName(UBound(RndArray(UBound(RndArray) - 1).RndName) + 1)
                 RndArray(UBound(RndArray) - 1).RndName(UBound(RndArray(UBound(RndArray) - 1).RndName) - 1) = RulerRS1.Fields("章节名称") '具有相同随机标识的章节名称数组
              End If
           End If
           End If
        End If
        '对多章节交叉随机的处理
        If IsNull(RulerRS1.Fields("全课程随机标识")) = False Then
           If RulerRS1.Fields("全课程随机标识") <> "" Then
           If UBound(RndArray) = 0 Then            '将第一个随机标识添加入随机标识数组
              ReDim Preserve RndArray(UBound(RndArray) + 1)
              ReDim RndArray(UBound(RndArray) - 1).RndName(1)
              RndArray(UBound(RndArray) - 1).RndFlag = RulerRS1.Fields("全课程随机标识") '随机标识
              RndArray(UBound(RndArray) - 1).RndName(0) = RulerRS1.Fields("章节名称")  '具有相同随机标识的章节名称数组
              RndArray(UBound(RndArray) - 1).RndNumber = Int(right(RndArray(UBound(RndArray) - 1).RndFlag, 1)) '随机选题题数<10
           Else
              LikeFlag = False
              For K = 0 To UBound(RndArray) - 1
                  If RndArray(K).RndFlag = RulerRS1.Fields("全课程随机标识") Then
                     LikeFlag = True
                     Exit For
                  End If
              Next K
              If LikeFlag = False Then
                 ReDim Preserve RndArray(UBound(RndArray) + 1)
                 ReDim RndArray(UBound(RndArray) - 1).RndName(1)
                 RndArray(UBound(RndArray) - 1).RndFlag = RulerRS1.Fields("全课程随机标识") '随机标识
                 RndArray(UBound(RndArray) - 1).RndName(0) = RulerRS1.Fields("章节名称")  '具有相同随机标识的章节名称数组
                 RndArray(UBound(RndArray) - 1).RndNumber = Int(right(RndArray(UBound(RndArray) - 1).RndFlag, 1)) '随机选题题数<10
              Else                                                                      '具有相同标识的只添加章节名称数组
                 ReDim Preserve RndArray(UBound(RndArray) - 1).RndName(UBound(RndArray(UBound(RndArray) - 1).RndName) + 1)
                 RndArray(UBound(RndArray) - 1).RndName(UBound(RndArray(UBound(RndArray) - 1).RndName) - 1) = RulerRS1.Fields("章节名称") '具有相同随机标识的章节名称数组
              End If
           End If
           End If
        End If
最佳答案
  • 五星知识达人网友:封刀令
  • 2021-05-02 22:57

dim RndArray()这个是动态数组


redim 改变大小。就是上标


ReDim Preserve 是改变组,保持原数组的值。

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯