一: 读入: Dim i%
Text1.text=””
Open app.path &”\\grade.txt” for input as #1 For i = 1 to 30 Input #1,a(i)
Text1.text1=text1.text& a(i)&space(2) Next i Close i 统计:
Dim sum%,i% Sum=0
For i =1 to 30
If a(i)=100 then Sum=sum+1 End if Next i
Text2.text=sum 二: 打开:
Dim s as string Text1.text=””
Open app.path&”\\infile.txt” for input as #1 Do while not eof(1) Line input #1,s
Text1.text=text1.text & s & vbcrlf Loop
Close #1
保存: Dim a%
a = Text1.Text
Text1.Text = UCase(a)
Open app.path& “\\outfile.txt” for output as #1 Print #1,text1.text Close#1
三:
读入整数: Dim i%
Open App.Path & \For i = 1 To 20 Input #1, a(i)
Text1.Text = Text1.Text & a(i) & Space(2) Next i
选择整数: Dim i%
For i = 1 To 20
If a(i) Mod 3 = 0 Then
Text2.Text = Text2.Text & a(i) & Space(2) End If Next i 四: 读入: Dim s$
Text1.Text = \
Open App.Path & \Do While Not EOF(1) Line Input #1, s
Text1.Text = Text1.Text & s & vbCrLf Loop 大写: Dim s1%
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 1) >= \ s1 = s1 + 1 End If Next i
Text2.Text = Str(s1) 小写: Dim s2%
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 1) >= \ s2 = s2 + 1 End If Next i
Text3.Text = Str(s2)
五:
Private sub drive1_change() Dir1.Path = Drive1.Drive End sub
Private sub dir1_change() File1.Path = Dir1.Path End sub
Private sub file1_click() Dim s$
If Right(File1.Path, 1) = \ Then s = File1.Path + File1.FileName Else
s = File1.Path + \End If
Text1.Text = s
以下题目不是书上的:
1.Dim s$
Open App.Path & \ s = Input(LOF(1), #1) Text1.Text = s Close #1
Open App.Path & \ Print #1, Text2.Text Close #1
2.Dim i%
Open App.Path & \ For i = 1 To 10 Input #1, a(i)
Text1.Text = Text1.Text & a(i) & Space(2) Next i
Close #1
For i = 1 To 10
If Left(a(i), 1) = \张\黄\ Text2.Text = Text2.Text & a(i) & Space(1) End If Next i
Open App.Path & \ Print #1, Text2.Text Close #1 3.
1.Text1.Locked = True fsave.Enabled = False
Text1.Locked = False fsave.Enabled = True 2.Text1.Text = \
Text1.Text = \计算机等级考试\