vb程序题(8)

上传人:简****9 文档编号:109663125 上传时间:2019-10-27 格式:DOCX 页数:7 大小:71.19KB
返回 下载 相关 举报
vb程序题(8)_第1页
第1页 / 共7页
vb程序题(8)_第2页
第2页 / 共7页
vb程序题(8)_第3页
第3页 / 共7页
vb程序题(8)_第4页
第4页 / 共7页
vb程序题(8)_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《vb程序题(8)》由会员分享,可在线阅读,更多相关《vb程序题(8)(7页珍藏版)》请在金锄头文库上搜索。

1、1文件a.txt中每行包括3列内容,分别为姓名,语文成绩,数学成绩。单击Command1按钮,程序计算出每名同学的总成绩,写入b.txt文件中。 a.txt文件格式示例 - 小红,80,90 小明,70,80 b.txt文件格式示例 - 小红,170“小明,150Option ExplicitPrivate Sub Command1_Click()Dim n$, c%, d%, e%Open a.txt For Input As #1Open b.txt For Output As #2Do While Not EOF(1)Input #1, n, c, de = c + dWrite #2,

2、 n, eLoopClose #1Close #2End Sub2.文件a.txt中每行包括2列内容,分别为姓名,成绩。单击Command1按钮,程序将a.txt文件中的各行,逆序写入b.txt文件中。 a.txt文件格式示例 -小红,90 小明,95 小刚,85 b.txt文件格式示例 - 小刚,85 小明,95 小红,90Option ExplicitPrivate Sub Command1_Click()Dim a$(1 To 10), b%(1 To 10), i%, j%Open a.txt For Input As #1Open b.txt For Output As #2i =

3、1Do While Not EOF(1)Input #1, a(i), b(i)i = i + 1LoopFor j = UBound(b) To LBound(b) Step -1If b(j) 0 ThenWrite #2, a(j), b(j)End IfNext jClose #2Close #1End Sub3. 文件a.txt中每行包括2列内容,分别为姓名,成绩。单击Command1按钮,程序将分数大于等于90分对应的行,写入b.txt文件中。 a.txt文件格式示例 -小红,90 小明,95 小刚,85 b.txt文件格式示例 - 小红,90 小明,95Option Explic

4、itPrivate Sub Command1_Click()Dim a$, b%Open a.txt For Input As #1Open b.txt For Output As #2Do While Not EOF(1)Input #1, a, bIf b = 90 ThenWrite #2, a, bEnd IfLoopClose #1Close #2End Sub4. 文件a.txt中每行包括2列内容,分别为姓名,成绩。单击Command1按钮,程序找出最高分所在行,将姓名和成绩写入b.txt文件中。 a.txt文件格式示例 -小红,90 小明,95小刚,85 b.txt文件格式示例

5、-小明,95Option ExplicitPrivate Sub Command1_Click()Dim a$, b%, c$, d%Open a.txt For Input As #1Open b.txt For Output As #2Do While Not EOF(1)Input #1, a, bIf b d Then d = b: c = aLoopWrite #2, c, dClose #1Close #2End Sub5. 复制文件。点击Command1按钮,程序将文件a.txt中的内容复制到文件b.txt中Option ExplicitPrivate Sub Command1_

6、Click()Dim a$Open a.txt For Input As #1Open b.txt For Output As #2Do While Not EOF(1)Line Input #1, aPrint #2, aLoopClose #2End Sub6. 文件a.txt中每行包含1个数。单击Command1按钮,程序将所有数排序后写入b.txt文件中. a.txt文件格式示例 -13 8 17 12 b.txt文件格式示例 -8 121317Option ExplicitPrivate Sub Command1_Click()Dim a%(1 To 12), i%, j%, k%,

7、 t%, h%, g%, sp$h = UBound(a): g = LBound(a): i = LBound(a)sp = App.Path & Open sp & a.txt For Input As #1Open sp & b.txt For Output As #2For i = 1 To 12Input #1, a(i)Next iFor j = 1 To 11For k = j To 12If a(j) a(k) Then t = a(j): a(j) = a(k): a(k) = tPrint a(j)Next kNext jFor j = 1 To 12If a(j) 0 Then Write #2, a(j)Next jClose #1Close #2End Sub

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号