写了一段代码:
Dim drs AS List(of Datarow)
Dim dr AS Datarow=e.Datarow
Dim filter1,filter2 AS String
filter1="[Replacement For] like '*" & e.Datarow("电池型号") & "*'"
filter2="[Replacement For] like '*" & e.Datarow("电池型号") & "*' and [Capacity]='" & e.Datarow("容量") & "'"
If e.Datacol.Name="电池型号" Or e.Datacol.Name="容量" Then
drs=Datatables("BPB量产电池").SELECT(filter2)
Dim n AS Integer=drs.count
If n=1 Then
Dim dr0 AS DATAROW=drs(0)
dr("BPBPN1")=dr0("产品名称")
dr("BPBPN2")=Nothing
dr("capacity2")=Nothing
dr("BPBPN3")=Nothing
dr("capacity3")=Nothing
Elseif n=1
Dim dr0 AS DATAROW=drs(0)
Dim dr1 AS Datarow=drs(1)
dr("BPBPN1")=dr0("产品名称")
dr("capacity2")=dr1("Capacity")
dr("BPBPN2")=dr1("产品名称")
dr("BPBPN3")=Nothing
dr("capacity3")=Nothing
Elseif n>2
Dim dr0 AS DATAROW=drs(0)
Dim dr1 AS Datarow=drs(1)
Dim dr2 AS Datarow=drs(2)
dr("BPBPN1")=dr0("产品名称")
dr("BPBPN2")=dr1("产品名称")
dr("capacity2")=dr1("Capacity")
dr("BPBPN3")=dr2("产品名称")
dr("capacity3")=dr2("Capacity")
Else n=0
dr("BPBPN1")="None"
dr("BPBPN2")=Nothing
dr("capacity2")=Nothing
dr("BPBPN3")=Nothing
dr("capacity3")=Nothing
END IF
END If
运行的时候,当"电池型号"输入字符而“容量”列无字符时,程序直接就跑到ELSE后面了,输出“NONE”,然后“容量”列输入字符后,才进行筛选。而我希望得到的结果是,当“电池型号”列有输入时,就出现初步的筛选结果,接着“容量”列输入后,再出现进一步的筛选结果。
请教:上面的程序段该怎么调整下?