求教大侠怎么才能筛选出超过10天的
求教大侠怎么才能筛选出超出10天的名单,并计算出超出的天数。 _DateDiff() _DateDiff()shqf 发表于 2014-5-26 10:53 http://www.autoitx.com/images/common/back.gif
正解! 过来看看,涨涨见识 帮你改了下!
#NoTrayIcon
#include <Date.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Access 操作实例", 320, 455, 553, 128)
$ListView1 = GUICtrlCreateListView("编号|姓名|借书日期|超过天数", 5, 5, 310, 200)
GUICtrlSendMsg(-1, 0x101E, 0, 50)
GUICtrlSendMsg(-1, 0x101E, 1, 70)
GUICtrlSendMsg(-1, 0x101E, 2, 50)
GUICtrlSendMsg(-1, 0x101E, 3, 100)
$Group1 = GUICtrlCreateGroup("创建/读取/修改/删除", 5, 210, 310, 60)
GUICtrlSetColor(-1, 0x0000FF)
$Button1 = GUICtrlCreateButton("创建", 10, 235, 75, 25)
$Button2 = GUICtrlCreateButton("读取", 85, 235, 75, 25)
$Button3 = GUICtrlCreateButton("修改", 160, 235, 75, 25)
$Button4 = GUICtrlCreateButton(" 删除", 235, 235, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("添加/修改记录", 5, 275, 310, 135)
GUICtrlSetColor(-1, 0xFF00FF)
$Input1 = GUICtrlCreateInput("", 55, 295, 96, 21)
;$Input3 = GUICtrlCreateInput("", 55, 355, 96, 21)
$Date1 = GUICtrlCreateDate("", 35, 348, 120, 25)
$Label1 = GUICtrlCreateLabel("姓名:", 15, 300, 31, 17)
$Label2 = GUICtrlCreateLabel("借书日期:", 15, 330, 71, 17)
;$Label3 = GUICtrlCreateLabel("超过天数:", 20, 360, 23, 17)
$Input2 = GUICtrlCreateInput("", 210, 295, 91, 21)
;$Input4 = GUICtrlCreateInput("", 210, 355, 91, 21)
$Date2 = GUICtrlCreateDate("", 180, 348, 120, 25)
$Label4 = GUICtrlCreateLabel("姓名:", 170, 300, 31, 17)
$Label5 = GUICtrlCreateLabel("借书日期:", 170, 330, 71, 17)
;$Label6 = GUICtrlCreateLabel("超过天数:", 170, 360, 23, 17)
$Button5 = GUICtrlCreateButton("添加", 45, 380, 75, 25)
$Button6 = GUICtrlCreateButton("保存修改", 195, 380, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("查询超过10天的:", 5, 410, 310, 40)
$Button7 = GUICtrlCreateButton("查询", 225, 420, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
$mdb_data_path = @ScriptDir & "\DB0.mdb"
$mdb_data_pwd = "123"
$T = "*"
$tblname = "mydb"
If FileExists($mdb_data_path) Then du()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If Not FileExists($mdb_data_path) Then
Else
MsgBox(0, '欢迎使用', '版权公有 传播不究')
EndIf
Case $Button2
du()
Case $Button3
$Strn = GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin = StringSplit($Strn, "|")
If $Strnspin = '0' Then
MsgBox(48, '提示', '请选择要更新的条目')
Else
EndIf
Case $Button4
$Strn = GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin = StringSplit($Strn, "|")
If $Strnspin = '0' Then
MsgBox(48, '提示', '请选择要删除的条目')
Else
;del()
du()
EndIf
Case $Button5
Case $Button6
Case $Button7
xun()
EndSwitch
WEnd
Func du()
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $T & " From " & $tblname)
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
$iDate = StringRegExpReplace($RS.Fields(2).value, '\D', '/')
$iDate = StringTrimRight($iDate, 1) & ' 00:00:00'
$iDays = _DateDiff('D', $iDate, _NowCalc())
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & $RS.Fields(1).value & "|" & $RS.Fields(2).value & '|' & $iDays, $ListView1)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>du
Func xun()
Global $11
$read10 = 10
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $T & " From " & $tblname & " WHERE ssex>'" & $read10 & "'")
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
$iDate = StringRegExpReplace($RS.Fields(2).value, '\D', '/')
$iDate = StringTrimRight($iDate, 1) & ' 00:00:00'
$iDays = _DateDiff('D', $iDate, _NowCalc())
If $iDays > 9 Then
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & $RS.Fields(1).value & "|" & $RS.Fields(2).value & '|' & $iDays, $ListView1)
GUICtrlSetData($11, $RS.Fields(2).value)
EndIf
$RS.movenext
WEnd
$RS.close
$addfld.close
EndFunc ;==>xun
回复 5# 水木子
非常感谢水木子大侠的指点,谢谢,非常谢谢 e 前来学习,感谢大神提供帮助 {:face (125):}撸主勤奋好学感天动地,坛子里的例程代码都要被改烂了,我辈典范,他日必成大器,有大器者有妹子 回复 8# 298311657
大侠就不要拿我取笑了,本人愚蠢至极,纯属好奇,出于娱乐,没有大侠有开拓进取之精神。
页:
[1]