可以用VB6编写考勤读取程序吗?求大神来看看
可以用VB6编写考勤读取程序吗?比如我想用VB6读取TXT文本里的数据,因为考勤数据是文本形式
我想用VB读取,读取名字,工号,自动计算迟到次数,未打卡次数(未打卡是几号)
在TAXT上显示出来, 这些VB能编写出来吗,能的话,该如何进行编写呢,
求大神给个步骤,和启发,谢谢了
本人VB不到2年,在学习中。
Option Explicit Dim conn As New ADODB.Connection Dim rs1 As New ADODB.Recordset Dim Str1 As String Dim Str2 As String Dim Str3 As String Dim strSQL As String Dim existName As Boolean Dim existDate As Boolean Const EaliestTime As Date = #12:00:00 AM# Const StartTime As Date = #8:00:00 AM# Const MiddleTime As Date = #12:00:00 PM# Const EndTime As Date = #5:00:00 PM# Const LastestTime As Date = #11:59:59 PM# Private Sub Combo1_Click() rs1.Close strSQL = "select * from Attendance where 姓名='" & Combo1.Text & "'" rs1.Open strSQL, conn, 1, 1 Set MSHFlexGrid1.DataSource = rs1 End Sub Private Sub Combo2_Click() rs1.Close strSQL = "select * from Attendance where 姓名='" & Combo1.Text & "'" & "and 日期=#" & Combo2.Text & "#" rs1.Open strSQL, conn, 1, 1 Set MSHFlexGrid1.DataSource = rs1 End Sub Private Sub Command1_Click() Dim i As Integer Dim status As String '0:normal 1:late 2:early 3:absent Dim TimePeriod(3) As Boolean Text1.Text = Combo1.Text & " " & Combo2.Text & "出勤情况" & vbCrLf Do While Not rs1.EOF If (rs1("时间") < StartTime) Then TimePeriod(0) = True If (rs1("时间") > StartTime And rs1("时间") < MiddleTime) Then TimePeriod(1) = True If (rs1("时间") > MiddleTime And rs1("时间") < EndTime) Then TimePeriod(2) = True If (rs1("时间") > EndTime And rs1("时间") < LastestTime) Then TimePeriod(3) = True rs1.MoveNext Loop If TimePeriod(0) And TimePeriod(3) Then status = "正常" If Not (TimePeriod(0)) And TimePeriod(3) Then status = "迟到" If TimePeriod(0) And Not (TimePeriod(3)) Then status = "早退" If Not (TimePeriod(0)) And Not (TimePeriod(1)) And Not (TimePeriod(2)) And Not (TimePeriod(3)) Then status = "旷工" Text1.Text = Text1.Text & status End Sub Private Sub Form_Load() Str1 = "Provider=Microsoft.Jet.OLEDB.4.0;" Str2 = "Data Source=c:\test.mdb;" Str3 = "Jet OLEDB:Database Password=" conn.Open Str1 & Str2 & Str3 strSQL = "select * from Attendance " rs1.Open strSQL, conn, 1, 1 Set MSHFlexGrid1.DataSource = rs1 iniCombo End Sub Sub iniCombo() Dim i As Integer Do While Not rs1.EOF existName = False existDate = False For i = 0 To rs1.RecordCount If (rs1("姓名") = Combo1.List(i)) Then existName = True: Exit For Next For i = 0 To rs1.RecordCount If (rs1("日期") = Combo2.List(i)) Then existDate = True: Exit For Next If existName = False Then Combo1.AddItem rs1("姓名") If existDate = False Then Combo2.AddItem rs1("日期") rs1.MoveNext Loop Combo1.Text = "选择姓名" Combo2.Text = "选择日期" End Sub