MBA智库

按键精灵txt判断

 

句子 = "度阿斯达娘阿婶是大的百度知道"
词 = "百度知道"
MyPos = Instr(句子, 词)
If MyPos > 0 Then 
    TracePrint "找到"
Else 
    TracePrint "没找到"
End If

  

(3)读取TXT文件指定某一行的第?到第?个字

UserVar t=2 "读出txt第几行文本"
UserVar i=5 "从第几个字开始读取"
UserVar O=8 "结束读取到第几个字"
Text = Plugin.File.ReadFileEx("路径\文件名.txt")
txtArray=Split(Text,"|")
I=I-1
O=O-I:T=T-1
For O
    str=str & Mid(txtArray(t),1+i,1)
    i=i+1
EndWhile 
MessageBox str
EndScript
复制代码

(4)新建一个TXT文件

set fso=CreateObject("Scripting.FileSystemObject")
const forwriting=2
const forreading=1
set myfile=fso.createtextfile("路径\文件名.txt")
复制代码

(5)判断一个文件是否存在

IsFile = Plugin.File.IsFileExit("路径\文件名.txt")
If IsFile = True
    MessageBox "找到"
Else 
    MessageBox "没找到"
EndIf 
复制代码

(6)给TXT文件写入内容

set fso=CreateObject("Scripting.FileSystemObject")
set myfile=fso.createtextfile("路径\文件名.txt")
myfile.writeline("内容")
Call Plugin.File.WriteFileEx("路径\文件名.txt", "内容")
复制代码

(7)读取TXT文件指定某一行内容

Text = Plugin.File.ReadFileEx("路径\文件名.txt")
txtArray=Split(Text,"|")
// 显示第5行,就写 txtArray(4) 。 显示第6行。就写 txtArray(5)
MessageBox txtArray(0)
复制代码

(8)读取TXT文件全部内容

I=0
Text = Plugin.File.ReadFileEx("路径\文件名.txt")
txtArray=Split(Text,"|")
While Len(txtArray(I))>=1
    RE=RE & txtArray(I)
    I=I+1
EndWhile 
MessageBox RE
复制代码

(9)读取txt文件一共多少行

I=0
Text = Plugin.File.ReadFileEx("路径\文件名.txt")
txtArray=Split(Text,"|")
While Len(txtArray(I))>=1
    I=I+1
EndWhile 
MessageBox i

  

posted @ 2017-12-29 09:19  冷色008  阅读(1159)  评论(0编辑  收藏  举报