VB语言如何实现同时满足多条件匹配过滤问题

只有http://pan.baidu.com/s/1ntkITV7
最好解析一下

Option Explicit

Private Sub JudgeFilter(ByRef nFilter() As Integer, ByVal myValue As Integer)
' 条件1
If myValue = 1 Or myValue = 2 Or myValue = 3 Then
nFilter(0) = nFilter(0) + 1
End If
' 条件2
If myValue = 2 Or myValue = 3 Or myValue = 6 Or myValue = 7 Or myValue = 8 Or myValue = 9 Then
nFilter(1) = nFilter(1) + 1
End If
' 条件3
If myValue = 1 Or myValue = 3 Or myValue = 6 Or myValue = 9 Or myValue = 10 Or myValue = 11 Then
nFilter(2) = nFilter(2) + 1
End If
' 条件4
If myValue = 11 Or myValue = 12 Or myValue = 13 Or myValue = 14 Or myValue = 15 Then
nFilter(3) = nFilter(3) + 1
End If
' 条件5
If myValue = 2 Or myValue = 5 Or myValue = 6 Or myValue = 9 Or myValue = 11 Or myValue = 15 Then
nFilter(4) = nFilter(4) + 1
End If
End Sub

Private Sub cmdGetArray_Click()
Dim arr(0 To 5) As Integer
Dim i As Integer
Dim j As Integer
Dim nFilter(0 To 4) As Integer
Dim nTemp As Integer
Dim bNotFind As Boolean
Dim sOutput As String
Dim bFindAList As Boolean

bFindAList = False
Do
' 初始化数组
For i = 0 To 4
nFilter(i) = 0
Next i

' 初始化随机数列
Randomize

' 生成1-15随机数序列
nTemp = Int(15 * Rnd + 1)
arr(0) = nTemp

JudgeFilter nFilter, arr(0) ' 判断条件

For i = 1 To 5
' 如果与之前的重复就重新生成一个随机数
Do
bNotFind = True
nTemp = Int(15 * Rnd + 1)
For j = 0 To i - 1
If nTemp = arr(j) Then
bNotFind = False
End If
Next j
Loop Until bNotFind = True
arr(i) = nTemp

JudgeFilter nFilter, arr(i) ' 判断条件
Next i

bFindAList = nFilter(0) >= 1 And nFilter(0) <= 2
bFindAList = bFindAList And nFilter(1) >= 1 And nFilter(1) <= 3
bFindAList = bFindAList And nFilter(2) >= 0 And nFilter(2) <= 2
bFindAList = bFindAList And nFilter(3) >= 0 And nFilter(3) <= 2
bFindAList = bFindAList And nFilter(4) >= 1 And nFilter(4) <= 2
Loop Until bFindAList

' 排序
For i = 0 To 4
For j = i + 1 To 5
If arr(i) > arr(j) Then
nTemp = arr(i): arr(i) = arr(j): arr(j) = nTemp
End If
Next j
Next i

' 输出
sOutput = ""
For i = 0 To 5
sOutput = sOutput + Format(arr(i), "00")
If i < 5 Then sOutput = sOutput + ","
Next i

edtOutputList.Text = sOutput + vbCrLf + edtOutputList.Text
End Sub追问

你给个源代码文件吧直接代码不行

追答

你得给我一个邮箱,我发给你

温馨提示:内容为网友见解,仅供参考
无其他回答

VB语言如何实现同时满足多条件匹配过滤问题
Private Sub JudgeFilter(ByRef nFilter() As Integer, ByVal myValue As Integer)' 条件1 If myValue = 1 Or myValue = 2 Or myValue = 3 Then nFilter(0) = nFilter(0) + 1 End If ' 条件2 If myValue = 2 Or myValue = 3 Or myValue = 6 Or myValue = 7 Or myValue ...

VB语言如何实现组合后多条匹配条件过滤输出问题
简单说就是循环套用,然后输出循环变量

求教VB 数据库 多个条件筛选语句的问题
应该是漏了单引号 如:select aa from TDLYZYTKZBB where zbdm='1'给你一个重要的技巧,但凡做sql的链接字符串时出现问题,先把你的连接字符串打印出来,再他打印出来的字符串拷贝到sql数据库中直接查询执行,让sql帮你找出语法的错误,如果sql能过,那你的连接字符串就没问题。参考资料:http:\/\/...

VB操作Excel中的AutoFilter时3个筛选条件的问题
自动筛选只能有两个条件,不过可以允许多个值筛选,采用下面的方法就可以了。Worksheets("Sheet1").Range("A1").AutoFilter_Field:=7, _Criteria1:=Array( "a","b","c"), Operator:=xlFilterValues

vb 多条件的if语句 如何实现如果满足条件1,条件2,条件3,条件4,条件...
再 next i,这又是矛盾了吧?3.程序里面的 else 是跟哪个if 匹配的???整个程序当中只有一个if,可是你却在else之前就end if了···这也不对吧?还望楼主自己再修改、调试下哈,我这没有vb,也不能帮你调试~~~程序写出来就是要调试的,呵呵~~希望能帮到楼主~~~参考资料:me···...

在vb中,如何对多种条件进行选择?
if (条件1=true) and (条件2=true) and (条件3=true) then '123 --- 1.11 10:06修改 --- 你说的这个问题,可以用数组来作啊。Function check(arr() As Boolean)check = True For i = 1 To UBound(arr)If Not arr(i) Then check = False Exit Function End If Next End Funct...

关于VB简单的数据条件过滤?
新建一个VB,加入4个CHECKBOX 一个COMMAND 和一个Label 复制以下代码就OK了 Private Sub Command1_Click()Dim gl gl = ","If Check1.Value Then gl = gl & Check1.Caption & ","If Check2.Value Then gl = gl & Check2.Caption & ","If Check3.Value Then gl = gl & Check3....

vb中case语句如果同时满足多个case条件执行哪一条
如果你一上来就说10岁以上的(>=10)分一组,那么全部人都会分到同一组了,再来找其他年龄段的就没有了。而如果先说40岁以上的(>=40)分一组,然后再说30岁以上的(>=30)分一组(这个时候40岁以上的已经在上一步中分走了,所以分到的就是30到39岁的了)就对了,同理,接下来再分20岁...

vb 实现满足多个条件中的一个就执行一个指定命令
dim a as string Randomize a = Int(Rnd * 20)image1.picture=loadpicture(app.path & "\\" & a & ".bmp")

vb if语法多条件判断
if (条件1 and 条件2 and 条件3) then '3个条件同时满足 结果1elseif (条件1 or 条件2 or 条件3) then'3个条件满足至少一个 结果2end if

相似回答
大家正在搜