求助如何写可以让grdDataGrid里的end_time如果小于系统时间也就是说超出end_time的时间没有归还能够用定义的颜色标记出来。谢谢各位小弟初学VB请大家一定帮忙,顺便问一下用“MsgBox”弹出的消息框的文本不能格式化(在应用中感觉字体太小)用什么方法可以代替“MsgBox”并请给个示例再次感谢大家!Option ExplicitPrivate Sub CancelButton_Click()
Unload Dialog
End SubPrivate Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End SubPrivate Sub OKButton_Click()
Text1.SetFocus
Dim bh As String
If Dialog.Text1.Text = "" Then
MsgBox "请输入资料条码号!"
Exit Sub
End If
bh = UCase(Dialog.Text1.Text)
Dim rs As Integer
If Not IsNumeric(Dialog.Text2.Text) Then
MsgBox "请输入人数!人数必须是整数!"
Exit Sub
End If
rs = CInt(Dialog.Text2.Text)
If rs < 0 Or rs > 8 Then
MsgBox "输入了错误的人数!人数必须在0到8之间!"
Exit Sub
End If
Dim stunum As String
stunum = Dialog.Text3.Text
Dim zwh As Integer
If Not IsNumeric(Dialog.Text4.Text) Then
MsgBox "请输入座位号!座位号必须是整数"
Exit Sub
End If
zwh = CInt(Dialog.Text4.Text)
If zwh < 0 Or zwh > 100 Then
MsgBox "输入了错误的座位号!座位号必须在0到100之间!"
Exit Sub
End If
Dim start_time As Date
start_time = Date + Time
Dim short_start_time As Date
short_start_time = Time
Dim short_end_time As Date
Dim end_time As Date
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDASQL;dsn=lxd;uid=;pwd=;"
Dim adoRS As New ADODB.Recordset
Dim tempsql As String
tempsql = "select zwh,zlno,stunum,rs,start_time,end_time,out_time from borrow where zwh=" & zwh
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
If Not adoRS.EOF Then
MsgBox "该座位已经有人了,请另选!"
Exit Sub
End If
adoRS.Close
tempsql = "select minutes,Cname,name,zlno from lxzlt where barcode='" & bh & "'"
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
If adoRS.EOF Then
MsgBox "该录像带不存在!"
Exit Sub
Else
If IsNull(adoRS("minutes")) Then
MsgBox "该录像带无时间属性,系统将默认为100分钟!"
end_time = DateAdd("n", 100, start_time)
short_end_time = DateAdd("n", 100, short_start_time)
Else
Dim minutes
minutes = adoRS("minutes")
end_time = DateAdd("n", minutes, start_time)
short_end_time = DateAdd("n", minutes, short_start_time)
End If
Dim zlmc As String
zlmc = adoRS("Cname")
If zlmc = "" Then
MsgBox "该影片无中文名,用英文名代替!"
zlmc = adoRS("name")
End If
Dim zlno As String
zlno = adoRS("zlno")
End If adoRS.Close
tempsql = "insert into borrow(zwh,zlmc,zlno,stunum,rs,start_time,end_time) values(" & zwh & ",'" & zlmc & "','" & zlno & "','" & stunum & "'," & rs & ",'" & short_start_time & "','" & short_end_time & "')"
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
tempsql = "update lxzlt set counts = counts -1 where barcode ='" & bh & "'"
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
' tempsql = "insert into tj(zlno,stuNum,date_time) values('" & zlno & "','" & stunum & "','" & start_time & "')"
' adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
Dim adoPrimaryRS As New ADODB.Recordset
adoPrimaryRS.Open "select zwh as 座位号,zlmc as 影片名,zlno as 片号,stunum as 学号,rs as 人数,start_time as 开始时间,end_time as 结束时间 from borrow Order by zwh", db, adOpenStatic, adLockOptimistic
Set frmborrow.grdDataGrid.DataSource = adoPrimaryRS
sizegrid
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
jishu = jishu + 1
frmborrow.Label1.Caption = "当前借阅总人数:" & CStr(jishu) 'Unload Dialog
End SubPrivate Sub Text1_keypress(keyascii As Integer)
If keyascii = 13 Then
Text2.SetFocus
End If
End SubPrivate Sub Text2_keypress(keyascii As Integer)
If keyascii = 13 Then
Text3.SetFocus
End If
End SubPrivate Sub Text3_keypress(keyascii As Integer)
If keyascii = 13 Then
Text4.SetFocus
End If
End SubPrivate Sub Text4_keypress(keyascii As Integer)
If keyascii = 13 Then
OKButton.SetFocus
End If
End Sub
Private Sub sizegrid()
frmborrow.grdDataGrid.Columns.Item(0).Width = 700
frmborrow.grdDataGrid.Columns.Item(1).Width = 3000
frmborrow.grdDataGrid.Columns.Item(2).Width = 1100
frmborrow.grdDataGrid.Columns.Item(3).Width = 1500
frmborrow.grdDataGrid.Columns.Item(4).Width = 900
frmborrow.grdDataGrid.Columns.Item(5).Width = 1100
frmborrow.grdDataGrid.Columns.Item(6).Width = 1100
End Sub
Unload Dialog
End SubPrivate Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End SubPrivate Sub OKButton_Click()
Text1.SetFocus
Dim bh As String
If Dialog.Text1.Text = "" Then
MsgBox "请输入资料条码号!"
Exit Sub
End If
bh = UCase(Dialog.Text1.Text)
Dim rs As Integer
If Not IsNumeric(Dialog.Text2.Text) Then
MsgBox "请输入人数!人数必须是整数!"
Exit Sub
End If
rs = CInt(Dialog.Text2.Text)
If rs < 0 Or rs > 8 Then
MsgBox "输入了错误的人数!人数必须在0到8之间!"
Exit Sub
End If
Dim stunum As String
stunum = Dialog.Text3.Text
Dim zwh As Integer
If Not IsNumeric(Dialog.Text4.Text) Then
MsgBox "请输入座位号!座位号必须是整数"
Exit Sub
End If
zwh = CInt(Dialog.Text4.Text)
If zwh < 0 Or zwh > 100 Then
MsgBox "输入了错误的座位号!座位号必须在0到100之间!"
Exit Sub
End If
Dim start_time As Date
start_time = Date + Time
Dim short_start_time As Date
short_start_time = Time
Dim short_end_time As Date
Dim end_time As Date
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDASQL;dsn=lxd;uid=;pwd=;"
Dim adoRS As New ADODB.Recordset
Dim tempsql As String
tempsql = "select zwh,zlno,stunum,rs,start_time,end_time,out_time from borrow where zwh=" & zwh
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
If Not adoRS.EOF Then
MsgBox "该座位已经有人了,请另选!"
Exit Sub
End If
adoRS.Close
tempsql = "select minutes,Cname,name,zlno from lxzlt where barcode='" & bh & "'"
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
If adoRS.EOF Then
MsgBox "该录像带不存在!"
Exit Sub
Else
If IsNull(adoRS("minutes")) Then
MsgBox "该录像带无时间属性,系统将默认为100分钟!"
end_time = DateAdd("n", 100, start_time)
short_end_time = DateAdd("n", 100, short_start_time)
Else
Dim minutes
minutes = adoRS("minutes")
end_time = DateAdd("n", minutes, start_time)
short_end_time = DateAdd("n", minutes, short_start_time)
End If
Dim zlmc As String
zlmc = adoRS("Cname")
If zlmc = "" Then
MsgBox "该影片无中文名,用英文名代替!"
zlmc = adoRS("name")
End If
Dim zlno As String
zlno = adoRS("zlno")
End If adoRS.Close
tempsql = "insert into borrow(zwh,zlmc,zlno,stunum,rs,start_time,end_time) values(" & zwh & ",'" & zlmc & "','" & zlno & "','" & stunum & "'," & rs & ",'" & short_start_time & "','" & short_end_time & "')"
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
tempsql = "update lxzlt set counts = counts -1 where barcode ='" & bh & "'"
adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
' tempsql = "insert into tj(zlno,stuNum,date_time) values('" & zlno & "','" & stunum & "','" & start_time & "')"
' adoRS.Open tempsql, db, adOpenStatic, adLockOptimistic
Dim adoPrimaryRS As New ADODB.Recordset
adoPrimaryRS.Open "select zwh as 座位号,zlmc as 影片名,zlno as 片号,stunum as 学号,rs as 人数,start_time as 开始时间,end_time as 结束时间 from borrow Order by zwh", db, adOpenStatic, adLockOptimistic
Set frmborrow.grdDataGrid.DataSource = adoPrimaryRS
sizegrid
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
jishu = jishu + 1
frmborrow.Label1.Caption = "当前借阅总人数:" & CStr(jishu) 'Unload Dialog
End SubPrivate Sub Text1_keypress(keyascii As Integer)
If keyascii = 13 Then
Text2.SetFocus
End If
End SubPrivate Sub Text2_keypress(keyascii As Integer)
If keyascii = 13 Then
Text3.SetFocus
End If
End SubPrivate Sub Text3_keypress(keyascii As Integer)
If keyascii = 13 Then
Text4.SetFocus
End If
End SubPrivate Sub Text4_keypress(keyascii As Integer)
If keyascii = 13 Then
OKButton.SetFocus
End If
End Sub
Private Sub sizegrid()
frmborrow.grdDataGrid.Columns.Item(0).Width = 700
frmborrow.grdDataGrid.Columns.Item(1).Width = 3000
frmborrow.grdDataGrid.Columns.Item(2).Width = 1100
frmborrow.grdDataGrid.Columns.Item(3).Width = 1500
frmborrow.grdDataGrid.Columns.Item(4).Width = 900
frmborrow.grdDataGrid.Columns.Item(5).Width = 1100
frmborrow.grdDataGrid.Columns.Item(6).Width = 1100
End Sub
解决方案 »
- 想做个自动删贴的工具,完全没有思路
- 出现问题请VB高手帮忙,我再用VB编写读非接触式IC卡程序。出现问题请VB高手帮忙
- vb怎样向Paradox表更新或添加记录
- 为什么生成不了真正的随即数?
- 100分求救!!帮帮忙了,有关datagrid
- 有在大连的朋友么?写软件的.我有房子要合组...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- vb 串口编程的一个小问题
- 关于image_click()和image_dblclick()的问题。
- 求解:在双击某一类型文件(如后缀名为.ABC)时,怎样把该文件中的数据自动装载到应用程序(如DKABC.EXE)中的一个变量里呢?
- 用ado打开一个连接,在程序中一直保持连接,是否会令程序变得很慢?
- 文本文件替换字符串求教高手,谢谢!!!
- 向用随机方式打开的文件中写入记录
-----------------------------------------------------------------------------自己作一个窗体来代替你的MSGBOX窗体!
msgboxForm.show 1
msgboxForm.show 1可不可以这样我在MsgBoxForm上写多个内容不同标签作为不同的消息框在各种条件下可以Show同一个窗体MsgBoxForm的不同标签?