设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 884|回复: 1
打印 上一主题 下一主题

[窗体] 能将下面的窗体vba代码加上中文注解,方便初学这学习吗?

[复制链接]
跳转到指定楼层
1#
发表于 2002-6-3 00:41:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Option Compare Database
Option Explicit

Const conNumButtons = 8
Const conFontWeightBold = 700
Const conFontWeightNormal = 400

Private Sub cmdExit_Click()
    CloseCurrentDatabase
End Sub

Private Sub cmdExit_GotFocus()
    Dim intOption As Integer
   
    'If the Exit Button has received the focus, turn off the focus on all the menu options
    For intOption = 1 To conNumButtons
        Me("Option" & intOption).Visible = False
        Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
    Next intOption

    ExitLabel.FontUnderline = True
End Sub

Private Sub cmdExit_LostFocus()
    ExitLabel.FontUnderline = False
End Sub

Private Sub cmdExit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ExitLabel.FontWeight = conFontWeightBold
End Sub

Private Sub cmdExit_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ExitLabel.FontWeight = conFontWeightNormal
End Sub

Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.

On Error GoTo Form_Open_Err

    ' Minimize the database window.
    DoCmd.SelectObject acForm, "Switchboard", True
    DoCmd.Minimize

    ' Move to the switchboard page that is marked as the default.
    Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'ĬÈÏ' "
    Me.FilterOn = True
   
Form_Open_Exit:
    Exit Sub

Form_Open_Err:
    MsgBox Err.Description
    Resume Form_Open_Exit
   
End Sub

Private Sub Form_Current()
' Update the caption and fill in the list of options.

    Me.Caption = Nz(Me![ItemText], "")
    FillOptions
   
End Sub

Private Sub FillOptions()
' Fill in the options for this switchboard page.

    ' The number of buttons on the form.
   
    Dim dbs As Database
    Dim rst As Recordset
    Dim strSQL As String
    Dim intOption As Integer
   
    ' Set the focus to the first button on the form,
    ' and then hide all of the buttons on the form
    ' but the first.  You can't hide the field with the focus.
    Me![Option1].Visible = True
    Me![Command1].Enabled = True
    Me![Command1].SetFocus
    With Me![OptionLabel1]
        .Visible = True
        .FontWeight = conFontWeightBold
    End With
    For intOption = 2 To conNumButtons
        Me("Option" & intOption).Visible = False
        Me("OptionLabel" & intOption).Visible = False
        Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
        Me("Command" & intOption).Enabled = False
    Next intOption
   
    ' Open the table of Switchboard Items, and find
    ' the first item for this Switchboard Page.
    Set dbs = CurrentDb()
    strSQL = "SELECT * FROM [Switchboard Items]"
    strSQL = strSQL & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]
    strSQL = strSQL & " ORDER BY [ItemNumber];"
    Set rst = dbs.OpenRecordset(strSQL)
   
    ' If there are no options for this Switchboard Page,
    ' display a message.  Otherwise, fill the page with the items.
    If (rst.EOF) Then
        Me![OptionLabel1].Caption = "´ËÇл»Ãæ°åҳûÓÐÏîÄ¿"
    Else
        While (Not (rst.EOF))
            Me("OptionLabel" & rst![ItemNumber]).Visible = True
            Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
            Me("Command" & rst![ItemNumber]).Enabled = True
            rst.MoveNext
        Wend
    End If

    ' Close the recordset and the database.
    rst.Close
    dbs.Close

End Sub

Private Function HandleFocus(intBtn As Integer)
' This function is called when a menu option receives the focus.
' intBtn indicates which button was clicked.

    Dim intOption As Integer

On Error GoTo HandleMouseOver_Err

    For intOption = 1 To conNumButtons
        'Show that this menu option has the focus...
        If intOption = intBtn Then
            Me("Option" & intOption).Visible = True
            Me("OptionLabe
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2002-6-3 04:07:00 | 只看该作者
你的中文在我的机子上全是乱码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-29 04:04 , Processed in 0.088174 second(s), 25 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表