Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of OpenTextFile method in VBS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "the use of OpenTextFile method in VBS". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the use of OpenTextFile method in VBS"!

Opens the specified file and returns a TextStream object that can be read, written, or appended to the file.

Object.OpenTextFile (filename [, iomode [, create [, format]])

Parameter object

Required. Expected the name of the FileSystemObject object.

Filename

Required. A string expression indicating the name of the file to open.

Iomode

Optional. The input / output mode is one of the following three constants: ForReading,ForWriting, or ForAppending.

Create

Optional. The Boolean value indicating whether a new file can be created if the specified filename does not exist. True when new files are allowed to be created, False otherwise. The default is False.

Format

Optional. One of the three Tristate values indicating the format in which to open the file. If you omit this parameter, the file is opened in ASCII format.

Set up

The iomode parameter can be one of the following settings:

The constant value describes that ForReading1 opens the file in read-only mode. You cannot write to this file. ForWriting2 opens the file in write-only mode. This file cannot be read. ForAppending8 opens the file and writes at the end of the file.

< P > the format parameter can be one of the following settings:

The constant value description TristateUseDefault-2 opens the file in the system default format. TristateTrue-1 opens the file in Unicode format. TristateFalse0 opens the file in ASCII format. Description

The following code illustrates how to open a write file using the OpenTextFile method:

Sub OpenTextFileTest Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, f Set fso = CreateObject ("Scripting.FileSystemObject") Set f = fso.OpenTextFile ("c:\ testfile.txt", ForWriting, True) f.Write "Hi, hello!" F.Close so far, I believe you have a deeper understanding of "the use of the OpenTextFile method in VBS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report