⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 很多的vb经典源代码
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "记事本"
   ClientHeight    =   3165
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   6615
   LinkTopic       =   "Form1"
   ScaleHeight     =   211
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   441
   StartUpPosition =   3  '窗口缺省
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   360
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   6615
      _ExtentX        =   11668
      _ExtentY        =   635
      ButtonWidth     =   609
      Appearance      =   1
      Style           =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   13
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "new"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "open"
            ImageIndex      =   2
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            ImageIndex      =   3
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "print"
            ImageIndex      =   4
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "cut"
            ImageIndex      =   5
         EndProperty
         BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "copy"
            ImageIndex      =   6
         EndProperty
         BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "paste"
            ImageIndex      =   7
         EndProperty
         BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "undo"
            ImageIndex      =   8
         EndProperty
         BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "redo"
            ImageIndex      =   9
         EndProperty
         BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   2760
      Top             =   1080
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   9
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0000
            Key             =   "new"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0114
            Key             =   "open"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0228
            Key             =   "save"
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":033C
            Key             =   "print"
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0450
            Key             =   "cut"
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0564
            Key             =   "copy"
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0678
            Key             =   "paste"
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":078C
            Key             =   "undo"
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":08A0
            Key             =   "redo"
         EndProperty
      EndProperty
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   3960
      Top             =   1080
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox TextEdit 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2820
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   360
      Width           =   6615
   End
   Begin VB.Menu mnuFile 
      Caption         =   "文件(&F)"
      Begin VB.Menu mnuFileNew 
         Caption         =   "新建(&N)..."
         Shortcut        =   ^N
      End
      Begin VB.Menu mnuFileOpen 
         Caption         =   "打开(&O)..."
         Shortcut        =   ^O
      End
      Begin VB.Menu mnuFileClose 
         Caption         =   "关闭(&C)"
      End
      Begin VB.Menu mnubar11 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileSave 
         Caption         =   "保存(&S)"
         Shortcut        =   ^S
      End
      Begin VB.Menu mnuFileSaveAs 
         Caption         =   "另存为(&A)..."
      End
      Begin VB.Menu mnubar12 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFilePage 
         Caption         =   "页面设置(&T)..."
      End
      Begin VB.Menu mnuFilePrint 
         Caption         =   "打印(&P)"
      End
      Begin VB.Menu DynaBar 
         Caption         =   "-"
         Visible         =   0   'False
      End
      Begin VB.Menu DynaMnu 
         Caption         =   ""
         Index           =   0
         Visible         =   0   'False
      End
      Begin VB.Menu mnubar13 
         Caption         =   "-"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "退出(&X)"
      End
   End
   Begin VB.Menu mnuEdit 
      Caption         =   "编辑(&E)"
      Begin VB.Menu mnuEditUndo 
         Caption         =   "撤消(&U)"
         Shortcut        =   ^Z
      End
      Begin VB.Menu mnuBar21 
         Caption         =   "-"
      End
      Begin VB.Menu mnuEditCut 
         Caption         =   "剪切(&T)"
         Shortcut        =   ^X
      End
      Begin VB.Menu mnuEditCopy 
         Caption         =   "复制(&C)"
         Shortcut        =   ^C
      End
      Begin VB.Menu mnuEditPaste 
         Caption         =   "粘贴(&P)"
         Shortcut        =   ^V
      End
      Begin VB.Menu mnuEditdel 
         Caption         =   "删除(&L)"
         Shortcut        =   {DEL}
      End
      Begin VB.Menu mnuBar22 
         Caption         =   "-"
      End
      Begin VB.Menu mnuEditAll 
         Caption         =   "全选(&A)"
         Shortcut        =   ^A
      End
      Begin VB.Menu mnuEditDate 
         Caption         =   "时间/日期(&D)"
         Shortcut        =   {F8}
      End
   End
   Begin VB.Menu mnuSerach 
      Caption         =   "搜索(&S)"
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "帮助(&H)"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub DynaMnu_Click(Index As Integer)
    Dim FileNo As Long
    FileNo = FreeFile
    Open DynaMnu(Index).Caption For Input As #FileNo
    TextEdit.Text = StrConv(InputB(LOF(FileNo), #FileNo), vbUnicode)
    Close #FileNo

End Sub

Private Sub Form_Resize()
   TextEdit.Width = Form1.ScaleWidth
   TextEdit.Height = Form1.ScaleHeight
   
   
End Sub

Private Sub mnuExit_Click()
   End
End Sub

Private Sub mnuFileClose_Click()
Me.Enabled = False
End Sub

Private Sub mnuFileOpen_Click()
 On Error Resume Next                    ' 设置错误处理
        Dim FileNo As Long
        CommonDialog1.CancelError = True
        CommonDialog1.Filter = "文本文件|*.txt|所有文件|*.*"
        CommonDialog1.InitDir = "C:\My Documents"
        CommonDialog1.Flags = &H200000              ' 允许使用长文件名
        CommonDialog1.ShowOpen
        If Err.Number = 32755 Then Exit Sub         ' 若按取消按钮,则退出过程
        Filename = CommonDialog1.Filename       ' 将要打开的文件名保存于变量中
    FileNo = FreeFile
    Open Filename For Input As #FileNo                 ' 打开文件
    ' 下面在TextEdit文本框中显示文件的内容
    TextEdit.Text = StrConv(InputB(LOF(FileNo), #FileNo), vbUnicode)
    Close #FileNo                                      ' 关闭文件
    ' 下面将文件添加记录到动态菜单中
       For n = 1 To MnuItemNum                   ' 检查是否已有同名项
             If DynaMnu(n).Caption = Filename Then   ' 若已有同名的,则不添加
                 Exit Sub
             End If
        Next
        MnuItemNum = MnuItemNum + 1
        Load DynaMnu(MnuItemNum)
        DynaMnu(MnuItemNum).Caption = Filename
        DynaMnu(MnuItemNum).Visible = True
        DynaBar.Visible = True
    

End Sub

Private Sub mnuFileSaveAs_Click()
On Error Resume Next
        Dim FileNo As Long
        CommonDialog1.CancelError = True
        CommonDialog1.Filter = "文本文件|*.txt|所有文件|*.*"
        CommonDialog1.InitDir = "C:\My Documents"
        CommonDialog1.Flags = &H200000
        CommonDialog1.ShowSave
        If Err.Number = 32755 Then Exit Sub
    Filename = CommonDialog1.Filename             ' 获得要保存的文件名
    FileNo = FreeFile
    Open Filename For Output As #FileNo            ' 以写的方式打开文件
    Print #FileNo, TextEdit.Text                     ' 将内容写入文件
    Close #FileNo                                  ' 关闭文件
    ' 下面将文件添加记录到动态菜单中
    
        For n = 1 To MnuItemNum
             If DynaMnu(n).Caption = Filename Then Exit Sub
        Next
        MnuItemNum = MnuItemNum + 1
        Load DynaMnu(MnuItemNum)
        DynaMnu(MnuItemNum).Caption = Filename
        DynaMnu(MnuItemNum).Visible = True
        DynaBar.Visible = True
    
End Sub

Private Sub TextEdit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then Form1.PopupMenu mnuEdit
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -