hsfl.net
当前位置:首页 >> vB中如何读取,写入txt文件 >>

vB中如何读取,写入txt文件

写入:Dim sr As New IO.StreamWriter(Application.StartupPath & "/写入的文本.txt") sr.WriteLine("写入的内容") sr.Close()读取:If (File.Exists(Application.StartupPath & "/msg.txt")) Then Dim fm As New IO.FileStream(Application.Sta...

Dim A, S As String Dim FreeNum As Integer FreeNum = FreeFile 'Freenum表示一个空闲的文件号 open "D:\date.txt" for input as #FreeNum '这步是打开“date.txt”,for input表示以输入方式(即读取文件)打开。如果要写入文件则应该用output或...

读取: Dim StringA As String Open "(此处输入txt路径)" For Input As #1 Input #1, StringA Close #1 Text1.Text = StringA 写入: Open "(此处输入txt路径)" For Output As #1 Input #1, Text1.Text Close #1 Holihand原创,yzhiyu_123的不行...

如果TXT文件是单行的话 Open "c:\1.txt" For Binary As #1 Text1.Text = Input(lof(1), 1) Close #1 Dim a a = Split(Text1.Text) 如果是多行要加循环 Option Explicit Dim a$, n%, k%, c$(), d% Private Sub Form_Click() n = 0 Open App.Path ...

Private Sub Form_Load() Dim str1 As String, str2 As String Open "c:\1.txt" For Input As #1 Do While (Not EOF(1)) Line Input #1, str1 str2 = str2 & Replace(str1, " ", "-") & "+16" & vbCrLf Loop Close Open "c:\2.txt" For Input As...

VB将文本框的数据读取和保存到文本文件中,实际上就是VB对txt的读写操作。 相关代码如下: 1、vb读取txt文件内容,以下代码实现把电脑txt中的内容读取到程序文本框text1中。 Private Sub Command1_Click() Open App.Path & "\123.txt" For Input...

Dim name As String = "" Dim age As Integer name = InputBox("请输入姓名") age = InputBox("请输入年龄") FileOpen(1, "d:\信息.txt", OpenMode.Append) WriteLine(1, name, age) FileClose(1) FileOpen(1, "d:\信息.txt", OpenMode.Input) D...

Using sw As New System.IO.StreamWriter(txt路径字符串) Using sr As New System.IO.StreamReader(txt路径字符串) Dim line As String While sr.Peek() >= 0 line = sr.ReadLine() If line.StartsWith("#a") Then sw.WriteLine("#a 600") Else ...

Open "c:\test.txt" For Input As #1 '把c:\test.txt换成你自己的文本文件名 While Not EOF(1) '只要没到文件尾部就一直循环 Line Input #1, strtmp '每次读取一行 str1 = Split(strtmp, ",") '把读取到的单行文本按逗号分隔成多个字符串,存放...

'以下是我做的一个例子,其功能是:统计D盘Mydir文件夹中文本文件data.txt中字符“R”出现的次数。并将统计结果写入到文本文件D:\Mydir\res.txt '已完成并调试成功,代码如下: '注意为使用FSO需先引用Microsoft Scripting Runtime Public FSO As ...

网站首页 | 网站地图
All rights reserved Powered by www.hsfl.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com