2道VB题 在线等

来源:百度知道 编辑:UC知道 时间:2024/06/28 07:35:29
1.在随机文件“C:\test.txt”的第3个位置插入一条记录,设变量student 与文件里的记录属于同一种自定义类型。代码如下:
open c:\test.txt for output as #1 len=len(student)
n=eof(1)/len(student)
for i=3 to n
get #1,i,student
print #1, i, student
next i
(为student赋值)
put #1,student,3
close “c:\test.txt ”
2.在一个数值类型的数组array(1 to 10)中,查找值为57的第一个元素。若找到返回该元素的位置,否则提示没有找到。
For i=10 to 1
If array(i)<>57 then exit for
Msgbx “没有找到”
Else
Positin=i
Endif
Next i
改错 程序里 哪里有错

问题不是很清楚,你不是编好了?还是找错误?如果是的话第二提exit for应该放在msgbox之后
第一题难看,而且不明白,改第二提吧,错得有点多
如果 for i=10 to 1 后面要加上step -1 否则改成for i=1 to 10 。msgbox 放在循环后面。程序可改为
for i=1 to 10
if array(i) =57 then
positin=i
x=1
else
x=0
endif
next
if x=0 then msgbox "没有找到"