Giáo trình Visual Basic 8 - Pdf 87

Members
Member Description
Default Read and write access permitted. This is the default.
Read Read access permitted.
ReadWrite Read and write access permitted.
Write Write access permitted.
Indicates how to open a file when calling file-access functions.
Remarks
When you call file access–related functions, you can use enumeration members in your code in place of the
actual values.
The OpenMode enumeration defines constants used to set file access modes. The following table lists the
OpenMode enumeration members.
Input, Output, and Append are used when sequentially accessing files, such as text files, while Binary is
used for binary file access and Random for random file access.
When sequentially accessing a file, you cannot change its data. You can read the data, append to it, or
overwrite it with new data. If you open it for input, the contents of the file will be overwritten, even if you do
not directly write to the file.
When performing file I/O operations, the My.Computer.FileSystem object provides greater performance
and ease of use than legacy file I/O methods. For more information, see My.Computer.FileSystem Object.
Members
Member Description
Append File opened to append to it. Default.
Binary File opened for binary access.
Input File opened for read access.
Output File opened for write access.
Random File opened for random access.
Indicates how to open a file when calling file-access functions.
Remarks
When you call file access–related functions, you can use enumeration members in your code in place of the
actual values.
The OpenShare enumeration defines constants that specify whether or not other processes can access the

Finally
' Check this again, since we need to make
sure we didn't throw an exception on open.
If (myStream IsNot Nothing) Then
myStream.Close()
End If
End Try
End If
End Sub
The Clipboard can be used to store data, such as text and images. Because the Clipboard is shared by all
processes, it can be used to transfer data between them. The My.Computer.Clipboard object allows you to
easily access the Clipboard and to read and write to it. The SetAudio, SetData, SetFileDropDownList,
SetImage, and SetText methods allow you to place data on the Clipboard.
Security Note:
Because the Clipboard can be accessed by other users, do not use it
to store sensitive information, such as passwords or confidential data.
To write text to the Clipboard
• Use the My.Computer.Clipboard.SetText method to write text to the Clipboard. The following
code writes the string "This is a test string" to the Clipboard.
Visual Basic
Copy Code
My.Computer.Clipboard.SetText("This is a test string.")
To write text to the Clipboard in a specific format
• Use the My.Computer.Clipboard.SetText method to write text to the Clipboard, including the
type of TextDataFormat. The following code writes the string "This is a test string" to the Clipboard as RTF
text.
Visual Basic
Copy Code
My.Computer.Clipboard.SetText("This is a test string.",
_

Visual Basic
Copy Code
Dim infoReader As System.IO.FileInfo
infoReader =
My.Computer.FileSystem.GetFileInfo("C:\testfile.txt")
MsgBox("File is " & infoReader.Length & " bytes.")
See Also
Concepts
My.Computer.FileSystem Object
My.Computer.FileSystem.GetFileInfo Method
File, Directory, and Drive Properties in Visual Basic
How to: Determine a File's Attributes in Visual Basic
The following table lists examples of tasks involving the My.Computer.FileSystem object.
To See
Read from a text file How to: Read From Text Files in Visual
Basic
Read from a delimited text
file
How to: Read From Comma-Delimited
Text Files in Visual Basic
Read from a fixed-width text
file
How to: Read From Fixed-width Text
Files in Visual Basic
Read from a text file with
multiple formats
How to: Read From Text Files with
Multiple Formats in Visual Basic
Read from a binary file How to: Read From Binary Files in
Visual Basic


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status