内容发布更新时间 : 2024/11/17 21:46:22星期一 下面是文章的全部内容请认真阅读。
【程序填空】
1、'题目:本程序执行后,最终在窗体上打印数字7。''请去掉_____,并填入正确的内容。 Private Sub Command1_Click() Dim a As String
'**********FILL**********
Open App.Path & \ n = 8
For I = 1 To n Print #1, I + 1 Next I Close #1
'**********FILL**********
Open App.Path & \ For I = 1 To n Input #1, a
If I Mod 5 = 0 Then
'**********FILL********** Print CInt(a) + _____ End If Next I Close #1 End Sub
Private Sub Form_Load() End Sub
2、本程序段将一个十进制整数m转换成 r (2-16)进制字符串'方法:将m不断除 r 取余数,直到商为零,以反序得到结果。 Function TranDec$(ByVal m%, ByVal r%) Dim StrDtoR$ Dim iB%, mr% StrDtoR = \ Do While m <> 0
'**********FILL********** mr = _____ m = m \\ r
If mr >= 10 Then
'**********FILL**********
StrDtoR = Chr(mr - 10 + _____) & StrDtoR Else
StrDtoR = mr & StrDtoR End If Loop
TranDec = StrDtoR End Function
Private Sub Command1_click() Dim m0%, r0%, i% m0 = Val(Text1.Text) r0 = Val(Text2.Text) If r0 < 2 Or r0 > 16 Then
i = MsgBox(\输入的R进制数超出范围\ If i = vbRetry Then Text2.Text = \ Text2.SetFocus Else End End If End If
Label3.Caption = \转换成\进制数\ '**********FILL********** Text3.Text = TranDec(m0, _____) End Sub
Private Sub Form_Load() End Sub
3、'题目:在窗体上设计两个文本框和两个标签,标签上显示\摄氏温度\和\华氏温度\,文本框一个用于输入摄氏温度数,一个用于输出对应的华氏温度?摄氏温度与华氏温度的转换公式为: c = (5 / 9) * (f - 32) 要求:对输入的摄氏温度数有检查功能,以拒绝接收非数字字符?运行界面如图所示 请在_____处填入正确的内容 Private Sub Command1_Click() Text1 = \ Text2 = \
Text1.Enabled = True Text2.Enabled = True Text1.SetFocus End Sub
Private Sub Command2_Click() End End Sub
Private Sub Form_Load() Text1 = \ Text2 = \
Text1.Enabled = False Text2.Enabled = False End Sub
Private Sub Text1_Change() '**********FILL**********
_____ = 5 * (Val(Text1.Text) - 32) / 9 End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 Then
'**********FILL**********
If Chr(KeyAscii) < \ '**********FILL********** KeyAscii = _____ End If End If End Sub
4、题目:本程序执行功能为,命令按钮单击一次后,窗体上输出结果为:'36' 25' 16 '9 ''请去掉_____,并填入正确的内容。 Private Sub Command1_Click() Dim xx(6) As Integer Dim k%
Open App.Path & \ For I = 1 To 6
'**********FILL********** j = _____ Print #1, j Next I Close #1
Open App.Path & \ k = 0
Do While Not EOF(2)
'**********FILL********** k = _____ Input #2, xx(k) Loop Close #2
'**********FILL********** For I = k To k / 2 Step_____ Form1.Print xx(I) Next I End Sub
Private Sub Form_Load() End Sub
5、题目:输入n个数,n由用户输入。 程序的功能是将输入的n个数反向输出? '请在_____处填入正确的内容 Private Sub Form_Load() Dim n As Integer Dim k As Integer Dim m As Integer Dim h As Integer Dim t As Integer Show
Dim a(100) As Single
n = Val(InputBox(\输入个数n\ Print \处理前数据 :\
'**********FILL********** For k = 1 To _____
a(k) = Val(InputBox(\请输入第\个数\ Print a(k); Next k Print
'**********FILL********** m = Int(_____) For k = 1 To m h = n - k + 1
'**********FILL********** t = a(h): _____: a(k) = t Next k
Print \处理的结果 :\ For k = 1 To n Print a(k); Next k End Sub
6、要求输入若干学生的成绩,计算平均分和高于平均分的人数,并将这两个数据放入数组的最后。
Private Sub Form_Click()
Dim mark() As Integer, i%, n%, aver n = InputBox(\输入学生的人数\ ReDim mark(1 To n) aver = 0
For i = 1 To n
mark(i) = Int(Rnd * 101) aver = aver + mark(i) Next i
'**********FILL**********
ReDim _____ mark(1 To n + 2) '增加两个元素,存放平均分和高于平均分的人数,原来的学生成绩仍保留 mark(n + 1) = aver / n mark(n + 2) = 0 For i = 1 To n
'**********FILL**********
If mark(i) > mark( ____ ) Then mark(n + 2) = mark(n + 2) + 1 Next i
For i = 1 To n
Print \
Next i
Print \平均分=\高于平均分人数=\End Sub
7、要求在Text1中输入一段字符,选中“大写转为小写小写转为大写”, '单击转换按钮后,Text2显示大小写相反的字符串;选中“全部小写”, '单击转换按钮后,Text2显示全部小写的字符串; '选中“全部大写”,单击转换按钮后,Text2显示全部大写的字符串。
'------------------------------------------------------- Private Sub Command1_Click()
Dim n As Integer, k As Integer, ch As String, a As String '**********FILL********** n = Len(_____) ch = \
For k = 1 To n
'**********FILL********** a = Mid(Text1.Text, _____,1) If Option1.Value = True Then If a >= \ ch = ch + UCase(a)
ElseIf a >= \ ch = ch + LCase(a) Else
ch = ch + a End If End If
If Option2.Value = True Then ch = UCase(Text1) End If
If Option3.Value = True Then ch = LCase(Text1) End If Text2 = ch
'**********FILL********** _____ End Sub
Private Sub Form_Load()
End Sub
8、下面的程序段用于实现以下功能: 利用冒泡法将一组整数从小到大排序? '
Private Sub Form_Click() Const n = 15