其实我的意思很简单
就是
If Trim(rs2.Fields("type1")) = Right(zyfp1_type, 5) Then
getTime
end if
If Trim(rs2.Fields("type2")) = Right(zyfp1_type, 5) Then
getTime
end if
If Trim(rs2.Fields("type3")) = Right(zyfp1_type, 5) Then
getTime
end if
If Trim(rs2.Fields("type4")) = Right(zyfp1_type, 5) Then
getTime
end if
而过程getTime中要处理的不同点就是判断type1,type2,type3,type4中哪一个
等于变量Right(zyfp1_type, 5),如type2=Right(zyfp1_type, 5),则
itemx.SubItems(8) = itemx.SubItems(8) & "," & rs2.Fields("type2") & "(" & mac_time & ")" '注意这里的type2
同理,如type3成立,则为
itemx.SubItems(8) = itemx.SubItems(8) & "," & rs2.Fields("type3") & "(" & mac_time & ")" '注意这里的type2
就是
If Trim(rs2.Fields("type1")) = Right(zyfp1_type, 5) Then
getTime
end if
If Trim(rs2.Fields("type2")) = Right(zyfp1_type, 5) Then
getTime
end if
If Trim(rs2.Fields("type3")) = Right(zyfp1_type, 5) Then
getTime
end if
If Trim(rs2.Fields("type4")) = Right(zyfp1_type, 5) Then
getTime
end if
而过程getTime中要处理的不同点就是判断type1,type2,type3,type4中哪一个
等于变量Right(zyfp1_type, 5),如type2=Right(zyfp1_type, 5),则
itemx.SubItems(8) = itemx.SubItems(8) & "," & rs2.Fields("type2") & "(" & mac_time & ")" '注意这里的type2
同理,如type3成立,则为
itemx.SubItems(8) = itemx.SubItems(8) & "," & rs2.Fields("type3") & "(" & mac_time & ")" '注意这里的type2
解决方案 »
- 高分求ActiveReport当前目录如何设置
- sendMessage的返回值为什么才是成功呢?api使用问题,超急!!!
- 我要取网络上一台计算机里的共享文件里的内容,该怎么办?
- 怎样得到Excel表中某SHEET中的行数和列数?
- 如何在文件中从指定位置读取指定长度的字符?
- 如何用vb实现在线注册和验证!!!
- 请问VB中是否有那种像资源管理器左半部分的控件。
- 两个text控件怎么和表里面的name和password比?(accsee)
- vb中mschart控件生成的柱型图是否能打印出来?
- 小问题,关于用鼠标移动无标题栏窗体的问题!
- 请问大虾如何在VB中如何根据数据来模拟三维地形?急急急
- 如何用代码控制 Datareport 中预览的显示比例?
Do While not .Eof
'
' 对 Type1...Type4 进行验证
'
For i = 1 to 4
If Trim(.Fields("Type" + CStr(i)).Value & "") = Right(zyfp1_type, 5) Then
'
' 调用过程
'
GetTime Trim(Fields("pay_id").Value & ""), Trim(Rs2.Fields("Type" + CStr(i)).Value & "")
End If
Next
.MoveNext
Loop
End With
' ------------------------------------------------------------------------------------
' 作用:
' 获得相关时间
' 参数:
' PayID String 查找的 ID 号
' FieldValues String 字段值
'
' 编写:Cityhunter([email protected])
' 日期:2002-10-19 9:44
' 版本:1.0
' ------------------------------------------------------------------------------------
Private Sub GetTime(ByVal PayID as String , ByVal FieldValues as String)
Dim strMac_time as String ' 临时存放 字段 strMac_time 值
'
' 查找
'
Rs3.Open "SELECT mac_time ' _
& "FROM machine ' _
& "WHERE pay_id ='" & Replace(Trim(PayID),"'","''") & "'",
cn, adOpenStatic
'
' 处理结果
'
With Rs3
Do While not .Eof
strMac_time = Trim(Fields("mac_time").Value & "")
If (strMac_time >= DTPStart.Value) And _
(strMac_time <= DTPEnd.Value) Then
'
' 向 itemx 增加
'
itemx.SubItems(8) = itemx.SubItems(8) & "," _
& Trim(FieldValues) _
& "(" & strMac_time & ")"
End If
.MoveNext
Loop
End With
End Sub
rs2.open "select pay_id,type1,type2,type3,type4 from payment where..."
with rs2
if not .eof then
.movefirst
do while not .eof
for i=0 to .Fields.Count-1 'i是自己声名一个变量
if Trim(.Fields(i)) = Right(zyfp1_type, 5) then getTime
next i
.movenext
loop
end if
end with
rs2.close
...
itemx.SubItems(8) = itemx.SubItems(8) & "," & rs2.Fields("type1") & "(" & mac_time & ")"
...
end if
If Trim(rs2.Fields("type2")) = Right(zyfp1_type, 5) Then
...
itemx.SubItems(8) = itemx.SubItems(8) & "," & rs2.Fields("type2") & "(" & mac_time & ")"
...
end if
.......,那和:If Trim(rs2.Fields("type1")) = Right(zyfp1_type, 5) Then
...
itemx.SubItems(8) = itemx.SubItems(8) & "," & Right(zyfp1_type, 5)& "(" & mac_time & ")"
...
end if
If Trim(rs2.Fields("type2")) = Right(zyfp1_type, 5) Then
...
itemx.SubItems(8) = itemx.SubItems(8) & "," & Right(zyfp1_type, 5) & "(" & mac_time & ")"
...
end if
......有什么区别?假设:type1至type4 有可能相同,则:
rs2.open "select pay_id,type1,type2,type3,type4 from payment where..."
for x=0 to rs2.recordcount-1
i=0
for j=1 to 4
If Trim(rs2.Fields("type"& j")) = Right(zyfp1_type, 5) Then
i=i+1
end if
next
pay_id = Trim(rs2.Fields("pay_id")) rs3.Open "select mac_time from machine where pay_id='" & pay_id & "' and mac_time >= " & DTPStart.Value & " and mac_time <= " DTPEnd.Value , cn, adOpenStatic If rs3.RecordCount <> 0 Then
For y = 0 To rs3.RecordCount - 1 for j= 1 to i
itemx.SubItems(8) = itemx.SubItems(8) & "," _
& Right(zyfp1_type, 5) _
& "(" & strMac_time & ")"
next
next
end if
next
......如果type1--type4不可能相同,就更简单了:
rs2.open "select pay_id,type1,type2,type3,type4 from payment where..."
for x=0 to rs2.recordcount-1
pay_id = Trim(rs2.Fields("pay_id")) rs3.Open "select mac_time from machine where pay_id='" & pay_id & "' and mac_time >= " & DTPStart.Value & " and mac_time <= " DTPEnd.Value , cn, adOpenStatic If rs3.RecordCount <> 0 Then
For y = 0 To rs3.RecordCount - 1 itemx.SubItems(8) = itemx.SubItems(8) & "," _
& Right(zyfp1_type, 5) _
& "(" & strMac_time & ")"
next
end if
next
.....