📄 ί
字号:
VERSION 5.00
Begin VB.Form Dialog
BorderStyle = 3 'Fixed Dialog
Caption = "打开"
ClientHeight = 3540
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 5325
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3540
ScaleWidth = 5325
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.FileListBox File1
Height = 2790
Left = 2700
TabIndex = 5
Top = 0
Width = 2595
End
Begin VB.TextBox Text1
Height = 270
Left = 2760
TabIndex = 4
Top = 2820
Width = 2475
End
Begin VB.DirListBox Dir1
Height = 3240
Left = 0
TabIndex = 3
Top = 300
Width = 2655
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 0
TabIndex = 2
Top = 0
Width = 2655
End
Begin VB.CommandButton CancelButton
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 4020
TabIndex = 1
Top = 3120
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "确定"
Default = -1 'True
Height = 375
Left = 2760
TabIndex = 0
Top = 3120
Width = 1215
End
End
Attribute VB_Name = "Dialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private curpath As String
Private Sub CancelButton_Click()
Form1.Tag = ""
Unload Me
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Text1.Text = File1.List(File1.ListIndex)
End Sub
Private Sub File1_DblClick()
Call OKButton_Click
End Sub
Private Sub Form_Load()
If LCase(Form1.Tag) = "open" Then Me.Caption = "打开": Text1.Locked = True
If LCase(Form1.Tag) = "save" Then Me.Caption = "保存": Text1.Locked = False
End Sub
Private Sub Form_Resize()
If Len(curpath) = 0 Then curpath = File1.Path Else Drive1.Drive = Left(curpath, 3): Dir1.Path = curpath
End Sub
Private Sub OKButton_Click()
Const st1 = "文件名不能包括以下字符:"
Const st2 = "\ / : * ? "" < > |"
If Len(Text1.Text) = 0 Then Call MsgBox("文件名不能为空", 16): Exit Sub
If InStr(Text1.Text, "/") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, "\") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, ":") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, "*") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, "?") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, """") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, "<") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, ">") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
If InStr(Text1.Text, "|") > 0 Then Call MsgBox(st1 & vbCrLf & st2, 16): Exit Sub
curpath = File1.Path
If Right(curpath, 1) <> "\" Then curpath = curpath & "\"
If Me.Caption = "打开" Then Form1.Tag = curpath & File1.FileName
If Me.Caption = "保存" Then Form1.Tag = curpath & Text1.Text
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -