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

📄 form1.frm

📁 很多的vb经典源代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form EditFrm 
   Caption         =   "文本编辑器"
   ClientHeight    =   3750
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6405
   LinkTopic       =   "Form1"
   ScaleHeight     =   3750
   ScaleWidth      =   6405
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command6 
      Caption         =   "退出(&X)"
      Height          =   375
      Left            =   5400
      TabIndex        =   6
      Top             =   0
      Width           =   975
   End
   Begin VB.CommandButton Command5 
      Caption         =   "编辑框只读"
      Height          =   375
      Left            =   4320
      TabIndex        =   5
      Top             =   0
      Width           =   1095
   End
   Begin VB.CommandButton Command4 
      Caption         =   "查找下一个"
      Height          =   375
      Left            =   3240
      TabIndex        =   4
      Top             =   0
      Width           =   1095
   End
   Begin VB.CommandButton Command3 
      Caption         =   "查找与替换"
      Height          =   375
      Left            =   2160
      TabIndex        =   3
      Top             =   0
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "保存文件"
      Height          =   375
      Left            =   1080
      TabIndex        =   2
      Top             =   0
      Width           =   1095
   End
   Begin VB.TextBox EditTXT 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   3310
      HideSelection   =   0   'False
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   440
      Width           =   6400
   End
   Begin VB.CommandButton Command1 
      Caption         =   "打开文件"
      Height          =   375
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   1095
   End
End
Attribute VB_Name = "EditFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Dim sFile, temp As String
sFile = InputBox("请输入要打开的文件名及路径:", "打开文件")
If Dir(sFile) <> "" Then
  Open sFile For Input As #1
  temp = StrConv(InputB(LOF(1), #1), vbUnicode)
  EditTXT.Text = temp
  Close #1
  EditFrm.Caption = "文本编辑器 — " & sFile
Else
  MsgBox "指定的文件" & sFile & "未找到!", 48, "文件打开"
End If

End Sub

Private Sub Command2_Click()
Dim sFile As String
sFile = InputBox("请输入保存的路径及文件名:", "保存文件")
Open sFile For Output As #1
Write #1, EditTXT.Text
Close #1
MsgBox "文件已成功保存!", 64, "保存文件"
EditFrm.Caption = "文本编辑器 — " & sFile
End Sub

Private Sub Command3_Click()
    Dim value As Integer
    ' 获取需要查找的字符串。
    Load searchDlg
    searchDlg.Show 1
    where = InStr(EditTXT.Text, search)     ' 在文本中查找字符串。
    If where Then   ' 如果找到,
        EditTXT.SelStart = where - 1  ' 设置选定的起始位置并
        EditTXT.SelLength = Len(search)   ' 设置选定的长度。
        value = MsgBox("替换吗?", 36, "查找与替换")
        If value = vbYes Then
           EditTXT.SelText = object
        End If
    Else
        MsgBox "字符串未发现", 64, "查找与替换"   ' 给出通知。
    End If

End Sub

Private Sub Command4_Click()
   Dim value As Integer
    ' 获取需要查找的字符串。
    where = InStr(where + Len(object), EditTXT.Text, search)  ' 在文本中查找字符串。
    If where Then   ' 如果找到,
        EditTXT.SelStart = where - 1  ' 设置选定的起始位置并
        EditTXT.SelLength = Len(search)   ' 设置选定的长度。
        value = MsgBox("替换吗?", 36, "查找与替换")
        If value = vbYes Then
           EditTXT.SelText = object
        End If
    Else
        MsgBox "搜索完毕", 64, "查找下一个" ' 给出通知。
    End If

End Sub

Private Sub Command5_Click()
  If Command5.Caption = "编辑框只读" Then
     EditTXT.Locked = True
     Command5.Caption = "取消只读"
  Else
     EditTXT.Locked = False
     Command5.Caption = "编辑框只读"
     EditTXT.SetFocus
  End If
  

End Sub

Private Sub Command6_Click()
    Dim value As Integer
    value = MsgBox("真的要退出吗?", 36, "文本编辑器")
    If value = vbYes Then
       End
    End If
End Sub

Private Sub Form_Resize()
    EditTXT.Top = 440
    EditTXT.Left = 0
    EditTXT.Width = EditFrm.ScaleWidth
    If EditFrm.WindowState <> 1 Then      '当窗体最小化时,则不执行下面语句
       EditTXT.Height = EditFrm.ScaleHeight - 440
    End If
End Sub

⌨️ 快捷键说明

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