正文

消息框中按钮之定义2005-09-20 22:05:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/iamben250/5057.html

分享到:

(1)
   消息框中按钮之定义

    MsgBox strMsg1, c1+c2+c3 , strMsg2

    其中  strMsg1   为提示信息

          strMsg2   为标题内容

          c1+c2+c3  定义按钮形式,具体如下:

          c1: 按钮的类型

            0    vbOkOnly             只有一个按钮“确定”
            1    vbOkCancel           两个按钮“确定”和“取消”
            2    vbAbortRetryIgnore   三个按钮“终止”、“重试”和“忽略”
            3    vbYesNoCancel        三个按钮“是”、“否”和“取消”
            4    vbYesNo              两个按钮“是”和“否”
            5    vbRetryCancel        两个按钮“重试”和“取消”

              返回值:  vbOk          1   确定
                        vbCancel      2   取消
                        vbAbort       3   终止
                        vbRetry       4   重试
                        vbIgnore      5   忽略
                        vbYes         6   是
                        vbNo          7   否

          c2: 图标的类型         

            16   vbCritical           ×
            32   vbQuesion            ?
            48   vbExclamation        !
            64   vbInformation        i

        c3: 默认焦点

            0    vbDefalaultButton1   左起第一个按钮自动获得焦点
            256  vbDefalaultButton2   左起第二个按钮自动获得焦点
            512  vbDefalaultButton3   左起第三个按钮自动获得焦点

        和为:   00  0000  0000 B
               c3   c2    c1

   例: 1.   i = MsgBox " 是否要删除该条记录 ? ", 1+32+0 , " 请确认"

        2.   MsgBox " 是否要删除 ! ", 0+32+0 , " 请...."


(2)
        判断表的存在

Function M_fucScanTable(strTName As String) As Integer ' 搜索表 strTableName
     On Error GoTo OpenErr
     Set MyRsm = New Recordset
   MyRsm.Open "Select * From " & strTName,Cn, adOpenKeyset, adLockOptimistic
        MyRsm.MoveLast
        M_fucScanTable = MyRsm.RecordCount        ' 返回记录数,0 为空表
        MyRsm.Close
        Set MyRsm = Nothin
        Exit Function
    OpenErr:
        M_fucScanTable = -1                                   ' 无表
    End Function   
(3)
    动态建立表
       strSQL = "CREATE TABLE " & strTName & _
        "( Xh char(3) Not Null Primary key,Mc char(10),Xb char(2)," & _
        "Csrq char(10),Zw char(20),Gz numeric(9,2),Bz char(30),Xp image )"
       cn.Execute strSQL, , adCmdText

       其中: Primary key 为设置主键(唯一)
(4)
    插入记录     Insert
  
       strSQL = "Insert Into A01(Xh,Mc,Xb,Csrq,Zw) " & _
       "Values ( '" & Xhp & "','" & Mcp & "','" & Xbp &"','" &Rqp& "','" & Zwp & "' "
       Cn.Execute strSQL
(5)
导出表格到excel
    Dim newxls As Excel.Application
    Dim newbook As Excel.Workbook
    Dim newsheet As Excel.Worksheet

    Set newxls = CreateObject("excel.application")
    newxls.Visible = True
    Set newbook = newxls.Workbooks.Add
    Set newsheet = newbook.Worksheets(1)
    For i = 0 To 7
        For j = 0 To 4
            MSFlexGrid1.Row = i
            MSFlexGrid1.col = j
            newsheet.Cells(1, 3) = Trim(Combo1.Text) & "班"
            newsheet.Cells(1, 4) = "第" & bytXq & "学期"
            newsheet.Cells(1, 5) = "课程表"
            newsheet.Cells(i + 3, j + 2) = Trim(MSFlexGrid1.TextMatrix(i, j))
        Next j
    Next i
    注意此项操作你先要 引用 excelctl type library 和 microsoft excel 9.0 object library

(6)   with 语句的应用
   With msflexgrid1
        .CellAlignment = 4
        .TextMatrix(1, 0) = "考试编号"
        .TextMatrix(1, 1) = "学号"
        .TextMatrix(1, 2) = "姓名"
        .TextMatrix(1, 3) = "班号"
        .TextMatrix(1, 4) = "课程名称"
        .TextMatrix(1, 5) = "分数"        
    End With
(7)
响应回车
Private Sub Text2_KeyPress(KeyAscii As Integer)                       ' Text2 响应回车键
    If KeyAscii = 13 Then
       Command1.SetFocus
    End If
End Sub
(8)
隐藏任务栏
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
            ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Sub Form_Load()
        SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
End Sub
希望能给您在编程时带来一点方便
同时我也只是起到一个抛砖引玉的 目的
希望您也能供稿 我方便大家努力
谢谢各位 vb 爱好者们

阅读(1962) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册