fold的翻译:这段vb代码有什么毛病啊?

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 13:54:15
Public rst As ADODB.Recordset
Dim i, s As Integer
Public newyear, newmonth, newdate As String
Private Sub Calendar1_Click()
Text1.Text = Calendar1.Year
Text2.Text = Calendar1.Month
newyear = Mid(Text1.Text, 3, 2)
newmonth = Text2.Text
newdate = newyear & newmonth
Calendar1.Visible = False
End Sub
Private Sub Label2_Click()
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=gzgl.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
con.Open
mysql = "select 员工信息.编号 as 编号,姓名,部门,职务,基本工资,津贴,伙食费,洗理,书报,交通,奖金 from 工资信息,员工信息 where 工资信息!日期='" & newdate & "' and 员工信息.编号=工资信息.编号"
Set rst = con.Execute(mysql)
s = rst.Fields.Count
If rst.BOF = True Or rst.EOF Then
MsgBox "没有您所要日期的工资信息!", 48, "警告"
Text1.SetFocus
Else
Set DataGrid1.DataSource = rst
For i = 0 To s - 1
DataGrid1.Columns(i).Alignment = dbgCenter
DataGrid1.Columns(i).Width = 1200
Next i
End If
End Sub
Private Sub Form_Load()
Calendar1.Visible = False
Text1.Locked = True
Text2.Locked = True
End Sub

Private Sub Form_Resize()
DataGrid1.Height = Me.Height - Label2.Height - 1200

End Sub

Private Sub Text1_Click()
Calendar1.Visible = True
End Sub
Private Sub Text2_Click()
Calendar1.Visible = True
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call Label2_Click
End If
End Sub

newdate格式不对,你想想你取得的年份是后两位,而一般现在的年份都是O几年,而数据库里的年份并不是这样的,所以对比的时候时间肯定对不上,故找不出符合的信息