MBA智库

按键精灵txt判断

 

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

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(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 @   冷色008  阅读(1214)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示