请问下面这道VB题目怎么做??谢谢啦 20
(1)单击读数据按钮,把考生文件夹下in4.dat文件中已按升序方式排列的60个数读入数组A,并显示在text1中(2)单击输入按钮,弹出一个输入对话框,接收用户输入的任...
(1)单击读数据按钮,把考生文件夹下in4.dat文件中已按升序方式排列的60个数读入数组A,并显示在text1中
(2)单击输入按钮,弹出一个输入对话框,接收用户输入的任意一个整数
(3)单击插入按钮,将输入的数插入A数组中合适的位置,使其仍保持A数组的升序排列,最后将A数组的内容重新显示在Text1中。代码如下:
Dim a(100) As Integer, num As Integer
Private Sub Command1_Click()
Dim k As Integer
Open App.Path & "\in4.dat" For Input As #1
For k = 1 To 60
Input #1, a(k)
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
Close #1
End Sub
Private Sub Command2_Click()
num = InputBox("请输入一个数")
End Sub
Private Sub Command3_Click()
For i = 1 To 60
'If num < a(i) Then ?
Next i
'For j = 60 To i ?
'a(j + 1) =?
Next j
'?= num
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
'For k = 1 To ?
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub 展开
(2)单击输入按钮,弹出一个输入对话框,接收用户输入的任意一个整数
(3)单击插入按钮,将输入的数插入A数组中合适的位置,使其仍保持A数组的升序排列,最后将A数组的内容重新显示在Text1中。代码如下:
Dim a(100) As Integer, num As Integer
Private Sub Command1_Click()
Dim k As Integer
Open App.Path & "\in4.dat" For Input As #1
For k = 1 To 60
Input #1, a(k)
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
Close #1
End Sub
Private Sub Command2_Click()
num = InputBox("请输入一个数")
End Sub
Private Sub Command3_Click()
For i = 1 To 60
'If num < a(i) Then ?
Next i
'For j = 60 To i ?
'a(j + 1) =?
Next j
'?= num
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
'For k = 1 To ?
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub 展开
3个回答
展开全部
Dim a(100) As Integer, num As Integer
Private Sub Command1_Click()
Dim k As Integer
Open App.Path & "\in4.dat" For Input As #1
For k = 1 To 60
Input #1, a(k)
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
Close #1
End Sub
Private Sub Command2_Click()
num = InputBox("请输入一个数")
End Sub
Private Sub Command3_Click()
For i = 1 To 60
'If num < a(i) Then exit for
Next i
For j = 60 To i step=-1
a(j + 1) =a(j)
Next j
a(i)= num
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
'For k = 1 To 61
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub
这段程序其实有点问题,它不能实现连续插入数字,只能插入一个数字。
Private Sub Command1_Click()
Dim k As Integer
Open App.Path & "\in4.dat" For Input As #1
For k = 1 To 60
Input #1, a(k)
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
Close #1
End Sub
Private Sub Command2_Click()
num = InputBox("请输入一个数")
End Sub
Private Sub Command3_Click()
For i = 1 To 60
'If num < a(i) Then exit for
Next i
For j = 60 To i step=-1
a(j + 1) =a(j)
Next j
a(i)= num
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
'For k = 1 To 61
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub
这段程序其实有点问题,它不能实现连续插入数字,只能插入一个数字。
展开全部
Private Sub Command3_Click()
For i = 1 To 60
If num < a(i) Then exit for
Next i
For j = 60 To i step -1
a(j + 1) =a(j)
Next j
a(i)= num
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
For k = 1 To 61
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub
For i = 1 To 60
If num < a(i) Then exit for
Next i
For j = 60 To i step -1
a(j + 1) =a(j)
Next j
a(i)= num
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
For k = 1 To 61
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-03-24
展开全部
Private Sub Command3_Click()
For i = 1 To 60
'If num < a(i) Then ?
if num < a(i) then exit for '''如果num值比当前位置a(i)值小就退出for循环。此时i值表示出现的位置。
Next i
'For j = 60 To i ?
for j=60 to i setp -1 '''从第60个位置第i个位置倒序后移。
'a(j + 1) =?
a(j+1)=a(j) ''''数据后移
Next j
'?= num
a(i)=num '''将num值填入i位置。完成。
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
'For k = 1 To ?
for k=1 to 61 '''此时有61个数了。
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub
For i = 1 To 60
'If num < a(i) Then ?
if num < a(i) then exit for '''如果num值比当前位置a(i)值小就退出for循环。此时i值表示出现的位置。
Next i
'For j = 60 To i ?
for j=60 to i setp -1 '''从第60个位置第i个位置倒序后移。
'a(j + 1) =?
a(j+1)=a(j) ''''数据后移
Next j
'?= num
a(i)=num '''将num值填入i位置。完成。
Text1 = ""
'以下程序段将插入后的数组A重新显示在Text1中
'For k = 1 To ?
for k=1 to 61 '''此时有61个数了。
Text1 = Text1 + Str(a(k)) + Space(2)
Next k
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询