Private Sub Form_Click ()
Dim I, Msg, Temp ' 声明变量。
On Error Resume Next ' 设置错误处理。
Msg = "Type anything you like into the text box below."
Text1.Text = InputBox(Msg) ' 取得用户正文。
Msg = "Choose OK to copy the contents of the text box "
Msg = Msg & "to the Clipboard."
MsgBox Msg ' 显示信息。
Clipboard.Clear ' 清除剪贴板。
Clipboard.SetText Text1.Text ' 将正文放置在剪贴板上。
If Clipboard.GetFormat(vbCFText) Then
Text1.Text = "" ' 清除该正文框。
Msg = "The text is now on the Clipboard. Choose OK "
Msg = Msg & "to copy the text from the Clipboard back "
Msg = Msg & "to the text box."
MsgBox Msg ' 显示信息。
Temp = Clipboard.GetText(vbCFText) ' 取得剪贴板正文。
For I = Len(Temp) To 1 Step -1 ' 使该正文反向。
Text1.Text = Text1.Text & Mid(Temp, I, 1)
Next I
Else
Msg = "There is no text on the Clipboard."
MsgBox Msg ' 显示错误信息。
End If
End Sub
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
Dim f
Set f = fs.OpenTextFile("c:\testfile.txt", ForReading)
Dim str
str = f.ReadAll
f.Close