sppk.net
当前位置:首页 >> VB如何指定读取文本文件的某一行 >>

VB如何指定读取文本文件的某一行

'添加 Command1 Command2 Text1 Text2 Label1 '在Text2输入欲读取第几行的行号,再点击Command1 'Command2是倒数第二行的内容 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long...

Open App.Path + "\1.txt" For Input As #1 Do While Not EOF(1) Dim tmp,As String Line Input #1, tmp ' InStr(1, tmp, "key")在这里找有没有变量的关键字,不然谁知道什么变量什么类型? Doevents Loop Close #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 = ...

VB可以使用二进制方式打开文本文件,以Get 语句读到字节数组,再使用StrConv 函数将其转换为字符串,而后使用Split函数文本的字符串数组及总句数,使用InputBox 函数来输入需要读某行文本。 Get 语句 将一个已打开的磁盘文件读入一个变量之中。 ...

Dim TextLine Dim ret as String Open "目录\a.txt" For Input As #1 ' 打开文件。 Do While Not EOF(1) ' 循环至文件尾。 Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。 '这时就是取到的第一行的值了,如果你确定每行都是这种格式...

Private Sub Command1_Click() Open App.Path & "\1.txt" For Binary As #1 T = Input(LOF(1), 1) Close #1 T1 = Split(T, vbCrLf) Dim T2(1 To 2) As String For i = 0 To UBound(T1) If InStr(1, T1(i), "a") > 0 Then i1 = i1 + 1 If i1 > UB...

Private Sub command1_click() Dim s1 As String Dim s2 As String Dim ss As String Dim tem As String Open "D:\123.txt" For Input As #1 Line Input #1, s1 Do While Not EOF(1) Line Input #1, tem If tem = "" And s1 = "" Then Line Inpu...

很简单,相当于寻找文件一样。 首先在声明里添加 Public success% Function FileExists%(fname$) On Local Error Resume Next Dim ff% ff% = FreeFile Open fname$ For Input As ff% If Err Then FileExists% = False Else FileExists% = True E...

Private Sub Form_Load() On Error Resume Next Open App.Path & "\ok.txt" For Input As #1 Do Until EOF(1) Line Input #1, x For Each i In Split(x, vbCrLf) If LCase(Right(i, 2)) = LCase("no") Then Text2.Text = Text2.Text & Trim(Spli...

Private Sub Form_click() Print ReadSomeLine("z:\1.txt", 3) End Sub Function ReadSomeLine(Str1 As String, LineN As Integer) Dim temp As String Dim a() As Variant, x As Integer Open Str1 For Input As #1 Do While Not EOF(1) Line I...

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