求助如何写可以让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

解决方案 »

  1.   

    你自己定做msgbox就行!!!很简单就是做一个窗体样式跟MSGBOX一样!!来个移花接木!!呵呵
      

  2.   

    顺便问一下用“MsgBox”弹出的消息框的文本不能格式化(在应用中感觉字体太小)用什么方法可以代替“MsgBox”并请给个示例再次感谢大家!
    -----------------------------------------------------------------------------自己作一个窗体来代替你的MSGBOX窗体!
      

  3.   

    谢谢如何写打开“MSGBOX窗体”的语句
      

  4.   

    自己写一下,然后用模式窗口的方式打开
    msgboxForm.show 1
      

  5.   

    谢谢非常感谢请教求助如何写可以让grdDataGrid里的end_time如果小于系统时间也就是说超出end_time的时间没有归还能够用定义的颜色标记出来。
      

  6.   

    自己写一下,然后用模式窗口的方式打开
    msgboxForm.show 1可不可以这样我在MsgBoxForm上写多个内容不同标签作为不同的消息框在各种条件下可以Show同一个窗体MsgBoxForm的不同标签?
      

  7.   

    添加一个窗体,并将其设置成消息框格式,就可以自由设置,在需要消息框的时候show 该窗体就可以了
      

  8.   

    MsgBox 的问题已经解决谢谢,关于数据集的问题大家在费心帮帮忙!真的谢谢大家。