📄 frmattribute.frm
字号:
VERSION 5.00
Begin VB.Form frmAttribute
Caption = "属性"
ClientHeight = 2535
ClientLeft = 45
ClientTop = 270
ClientWidth = 2670
LinkTopic = "Form5"
MaxButton = 0 'False
ScaleHeight = 2535
ScaleWidth = 2670
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 372
Left = 1560
TabIndex = 2
Top = 2040
Width = 855
End
Begin VB.CommandButton cmdOK
Caption = "设定"
Default = -1 'True
Height = 372
Left = 240
TabIndex = 1
Top = 2040
Width = 855
End
Begin VB.Frame Frame1
Caption = "属性列表"
Height = 1695
Left = 120
TabIndex = 0
Top = 120
Width = 2412
Begin VB.CheckBox chkNormal
Caption = "常 规"
Height = 372
Left = 240
TabIndex = 7
Top = 240
Width = 972
End
Begin VB.CheckBox chkReadOnly
Caption = "只 读"
Height = 372
Left = 1320
TabIndex = 6
Top = 240
Width = 972
End
Begin VB.CheckBox chkArchive
Caption = "存 档"
Height = 372
Left = 240
TabIndex = 5
Top = 1200
Width = 972
End
Begin VB.CheckBox chkHidden
Caption = "隐 藏"
Height = 372
Left = 240
TabIndex = 4
Top = 720
Width = 972
End
Begin VB.CheckBox chkSystem
Caption = "系 统"
Height = 372
Left = 1320
TabIndex = 3
Top = 720
Width = 972
End
End
End
Attribute VB_Name = "frmAttribute"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim msFileName As String
Private Sub cmdOK_Click()
Dim nFileAttr As Integer
nFileAttr = 0 '属性变量初始化
'根据复选框的值,来决定文件或者文件夹的属性
If chkNormal.Value = 1 Then nFileAttr = nFileAttr + vbNormal
If chkReadOnly.Value = 1 Then nFileAttr = nFileAttr + vbReadOnly
If chkHidden.Value = 1 Then nFileAttr = nFileAttr + vbHidden
If chkSystem.Value = 1 Then nFileAttr = nFileAttr + vbSystem
If chkArchive.Value = 1 Then nFileAttr = nFileAttr + vbArchive
SetAttr msFileName, nFileAttr '设置文件属性
Unload frmAttribute
End Sub
Private Sub cmdCancel_Click()
Unload frmAttribute
End Sub
Public Property Get FileName() As String
FileName = msFileName
End Property
Public Property Let FileName(ByVal strFile As String)
On Error Resume Next
msFileName = strFile '给FileName属性赋值
If Dir(msFileName) <> "" Then
'如果文件名代表的是一个文件
Me.Caption = "查看文件的属性"
Else
If Dir(msFileName, vbDirectory) <> "" Then
'如果文件名代表的是一个文件夹
Me.Caption = "查看文件夹的属性"
End If
End If
Dim nAttr As Integer
nAttr = GetAttr(msFileName) '读取被选文件的属性
'对文件属性作出判断,设置对应的属性检查框
chkNormal.Value = IIf((nAttr And vbNormal) > 0, 1, 0)
chkReadOnly.Value = IIf((nAttr And vbReadOnly) > 0, 1, 0)
chkHidden.Value = IIf((nAttr And vbHidden) > 0, 1, 0)
chkSystem.Value = IIf((nAttr And vbSystem) > 0, 1, 0)
chkArchive.Value = IIf((nAttr And vbArchive) > 0, 1, 0)
End Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -