sppk.net
当前位置:首页 >> vB如何读取文本文件中指定内容 >>

vB如何读取文本文件中指定内容

代码: Private Sub Command_Click() Dim a As String Open "C:\\mytext.txt" For Input As #1 Do While Not EOF(1) Line Input #1, a Text1.Text=Text & a & vbCrLf Loop Close #1

Private Sub Command1_Click() Open "C:\123.txt" For Input As #1 n = 0 Do While Not EOF(1) Line Input #1, a n = n + 1 If n = 3 Then Text1.Text = a Exit Do End If Loop Close #1 End Sub 这样就可以了。用n来控制行数。当到达了第三行,...

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行而已。。

'这个代码有要求:每个数据不能大于8个字符(tab键默认的所占的字符长度) Private Sub Form_Click() '请点击窗体 Me.Cls Dim xRow, yLine, i, j As Long, Temp As String, Arr(1 To 99) As String xRow = Val(InputBox("输入行数:")) yLine = ...

1.读取某个指定字节 Private Sub Command1_Click() Dim a() As Byte, b As Byte, i As Integer, j, S As String 'S = App.Path & "\1.txt" '请修改为实际文件名 S = "C:\Documents and Settings\Administrator\桌面\1.txt" ReDim a(FileLen(S)) ...

定义一个变量记录读到了第几行。 Dim txt As String, i As LongOpen "C:\a1.txt" For Input As #1Open "C:\a2.txt" For Output As #2Do While Not EOF(1) Line Input #1, txt i = i + 1 If i = 6 Then txt = "f=4888" Print #2, txtLoopClose

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

Dim xx() As String, aa As IntegerPrivate Sub Command1_Click()Text1.Text = "" '清空文本框,这样可以多次点击按钮得到不同的内容Dim zz As IntegerRandomizezz = Int(Rnd * aa + 1) '得到一个随机数Text1.Text = xx(zz) '在文本框显示随机数...

dim num() dim i as long i=0 ReDim ri(0) Open "C:\SAM.txt" For Input As #1 ' 打开文件。 Do While Not EOF(1) '循环至文件尾。 Line Input #1, TextLine '读入一行数据并将其赋予某变量。 num(i)=TextLine i=i+1 ReDim Preserve ri(i) Loop ...

VB中可以在循环中使用Line Input # 语句一行行读入文本,直到到达文件的结尾。 Line Input # 语句,从已打开的顺序文件中读出一行并将它分配给 String变量。 EOF 函数,返回一个 Integer,它包含 Boolean 值 True,表明已经到达为 Random 或顺序...

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