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

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

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或...

如果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_click() Dim a$ Open "c:\1.txt" For Input As #1 Do Input #1, a Text1.Text = Text1.Text & a & vbCrLf Loop Until EOF(1) Close #1 End Sub 貌似1楼的只能读取1行而已。。

读取: 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的不行...

新建工程,在窗体中加入2个文本框一个命令按钮,点“工程”菜单——添加模块,在模块在代码窗口中输入下列代码:Type student_data '在模块中添加学生记录结构的定义name As String * 12Sex As String * 12End Type在窗体的代码窗口中输入下列代码:...

写入: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(),k open"txt的路径"for input as #1 do until eof(#1) redim a(k) input #1,a(k) k=k+1 loop

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

方法1: Open "c:\1.txt" For Output As #1 'c:\1.txt为保存文件 Print #1, Text1 & Text2 & Text3 &..... '将多个文本框内容用&合并在一起 写入内容 Close #1 '关闭文件 方法2: Dim aa As String aa =Text1 & Text2 & Text3 &..... '将多个文...

给你一个参考程序。测试正常。朋友 Option Base 1 '运行程序前,先在D盘上创建test和test_new两个文件夹 Private Sub Command1_Click() '创建五个.txt文件存放于test中 Dim a%(5, 5), k%, f% For f = 1 To 5 Open "d:/test/" & f & ".txt" For O...

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