Private Sub Command1_Click()
Clipboard.SetText Text1.SelText
End Sub
Private Sub Command2_Click()
If Len(Clipboard.GetText) Then
Text1.SelText = Clipboard.GetText
End If
End Sub
Private Sub Form_Load()
Command1.Enabled = False
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Command1.Enabled = Text1.SelLength >0
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Butt Then
Command1.Enabled = Text1.SelLength >0
End If
End Sub
比如Text1的内容为abc,而当前只选中了第一个字符a
那么Text1.text表示文本框的全部内容,即abc
而Text1.SelText表示文本框中当前选中的内容,即a--selText是select text(选中文字)的缩写
用API函数 SHFileOperation的方法。
以下是使用SHFileOperation删除复制移动文件的例子,可以复制文件夹
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String '只有在 FOF_SIMPLEPROGRESS 时用
End Type
Private Declare Function SHFileOperation Lib _
"shell32.dll" Alias "SHFileOperationA" (lpFileOp _
As SHFILEOPSTRUCT) As Long
'wFunc 常数
'FO_COPY 把 pFrom 文件拷贝到 pTo。
Const FO_COPY = &H2
'FO_DELETE 删除 pFrom 中的文件(pTo 忽略)。
Const FO_DELETE = &H3
'FO_MOVE 把 pFrom 文件移动到 pTo。
Const FO_MOVE = &H1
'fFlag 常数
'FOF_ALLOWUNDO 允许 Undo 。
Const FOF_ALLOWUNDO = &H40
'FOF_NOCONFIRMATION 不显示系统确认对话框。
Const FOF_NOCONFIRMATION = &H10
'FOF_NOCONFIRMMKDIR 不提示是否新建目录。
Const FOF_NOCONFIRMMKDIR = &H200
'FOF_SILENT 不显示进度对话框
Const FOF_SILENT = &H4
Private Sub Command1_Click()
'例子:
Dim SHFileOp As SHFILEOPSTRUCT
' 拷贝
SHFileOp.wFunc = FO_COPY
SHFileOp.pFrom = "d:\MASM611"
SHFileOp.pTo = "c:\MASM611"
SHFileOp.fFlags = FOF_NOCONFIRMMKDIR
Call SHFileOperation(SHFileOp)
End Sub
或者用命令行
shell "cmd.exe /c xcopy "+chr(34)+"C:\新建文件夹 c:\aa /q /e" +chr(34)
用API函数 SHFileOperation的方法。
以下是使用SHFileOperation删除复制移动文件的例子,可以复制文件夹
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String '只有在 FOF_SIMPLEPROGRESS 时用
End Type
Private Declare Function SHFileOperation Lib _
"shell32.dll" Alias "SHFileOperationA" (lpFileOp _
As SHFILEOPSTRUCT) As Long
'wFunc 常数
'FO_COPY 把 pFrom 文件拷贝到 pTo。
Const FO_COPY = &H2
'FO_DELETE 删除 pFrom 中的文件(pTo 忽略)。
Const FO_DELETE = &H3
'FO_MOVE 把 pFrom 文件移动到 pTo。
Const FO_MOVE = &H1
'fFlag 常数
'FOF_ALLOWUNDO 允许 Undo 。
Const FOF_ALLOWUNDO = &H40
'FOF_NOCONFIRMATION 不显示系统确认对话框。
Const FOF_NOCONFIRMATION = &H10
'FOF_NOCONFIRMMKDIR 不提示是否新建目录。
Const FOF_NOCONFIRMMKDIR = &H200
'FOF_SILENT 不显示进度对话框
Const FOF_SILENT = &H4
Private Sub Command1_Click()
'例子:
Dim SHFileOp As SHFILEOPSTRUCT
' 拷贝
SHFileOp.wFunc = FO_COPY
SHFileOp.pFrom = "d:\MASM611"
SHFileOp.pTo = "c:\MASM611"
SHFileOp.fFlags = FOF_NOCONFIRMMKDIR
Call SHFileOperation(SHFileOp)
End Sub
或者用命令行
shell "cmd.exe /c xcopy "+chr(34)+"C:\新建文件夹 c:\aa /q /e" +chr(34)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)