题目
阅读以下说明及Visual Basic 程序代码,将应填入(n)处的字句写在对应栏内。
[程序5.1说明]
下列程序运行时,当单击窗体后,从键盘输入一个字符,判断该字符是字母字符、数字字符还是其他字符,并做相应的显示。窗体上无任何控件,并禁用Ase和Chr函数,Select Case语句中禁用枚举值。
[Visual Basic代码]
Private Sub Form. Load ()
Dim x As String*1
X=(1) (“请输入单个字符”,“字符”)
Select Case UCase ((2) )
Case (3)。
Print X+“是字母字符”
Case (4)
Print X+ “是数字字符”
Case Else
Print X+“是其他字符”
End Select
[程序5.2说明]
在窗体上画一个名称为Timer1的计时器和一个名称为Labe11的标签。当运行程序后,将在标签中显示当前时间的数字时钟(包括时:分:秒)。
[Visual Basic代码]
Private Sub Fom_Load ()
Timer1.Interval=1000
EndSub
Private Sub Timer1_ timer() (5)
EndSub
第1题
阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。
【说明】
以下程序为求行列式X(5,5)的值S。
【Visual Basic代码】
Private Function col (byval x (5,5 ) as integer ) as long
dim fesult as long
dim temp as long
dim I as integer
dim j as integer
dim k as imeger
result = 0
for I = to 5
(1)
for j = 1 to 5
if I+j>6 then
k= (1+j ) mod 5
else
k=1
endif
temp=temp*x (k,j )
(2)
result=(3)
(4)
(5)
End function
第2题
阅读以下说明及Visual Basic 程序代码,将应填入(n)处的字句写在对应栏内。
[说明]
本程序求3~100之间的所有素数(质数)并统计个数;同时将这些素数从小到大依次写入顺序文件E: \dataout.txt;素数的个数显示在窗体Form1上。
[Visual Basic 代码]
Private Sub Command1_ Click ()
Dim count as integer, flag as Boolean
Dim t1 as Integer, t2 as Integer
(1)
Count=0
For t1=3 to 100
Flag=Tree
For t2=2 to Int(Sqr (t1 ) )
If (2) Then flag=False
Next t2
(3)
count=(4)
write 1, t1
End if
Next t1
(5)
Close 1
End Sub
第3题
阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。
【说明】
在窗体上设计两个文本框和两个标签,标签上显示:“摄氏温度:”和“华氏温度:”,文本框一个用于输入摄氏温度数,一个用于输出对应的华氏温度。摄氏温度与华氏温度的转换公式为:c=(5/9)×(f-32)
要求:对输入的摄氏温度数有检查功能,以拒绝接收非数字字符。运行界面如图所示。
【Visual Basic代码】
Private Sub Commandl_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 Textl_Change ()
Text2.Text = (1)
End Sub
Private Sub Textl_KeyPress (KeyAscii As (2) )
If (3) Then
If Chr (KeyAscii ) < "0" Or (4) Then
(5)
End If
End If
End Sub
第4题
●试题六
阅读以下应用说明及Visual Basic部分程序代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
单击窗体上的"测试"(cmdTest)按钮,出现一个输入框,要求输入一串字符,将该字符串中的非字母字符删除后,显示在窗体中的一个文本框(txtShow)中。
【程序代码】
Private Sub cmdTest_Click()
Dim strT1,strT2 As String
Dim strCh As (1)
Dim intL As Integer
Dim intI As Integer
strT1= (2) ("请输入一串字符","字符串输入")
intL= (3)
strT2=″″
For intI=l To intL
strCh=Mid(strT1,intI,1)
If(strCh>"A"And (4) ) Or (strCh>"a" And suCh<"z")Then
strT2=strT2+strCh
End If
Next intI
txtShow.Text= (5)
End sub
第5题
●试题五
阅读以下应用说明、属性设置及Visual Basic程序代码,将应填入(n)处在字句写在答题纸的对应栏内。
【说明】
本应用程序的运行窗口如图2所示。
只要用户单击"闪烁"按钮,文字"欢迎光临"就会以0.3秒消失、0.3秒显示反复进行闪烁;单击"停止"按钮时,闪烁停止,恢复图示的初态。
在开发过程中,需要设置的属性如表1所示。
在开发过程中,需要编写的程序代码如下:
【程序】
Private Sub CmdF_Click()
Timer1. (3) =True
Labe1.Visible=False
End Sub
Private Sub Timer1_Timer()
(4) =not Label.Visible
End Sub
Private Sub CmdT_Click()
Timer1.Enabled= (5)
Labe1.Visible=true
End Sub
第6题
阅读以下关于某绘图系统的技术说明、部分UML类图及Visual Basic程序,将Visual Basic程序中(1)~(6)空缺处的语句填写完整。
【说明】
某绘图系统定义了一个抽象类Ishape,现有3个类Cpoint,CLine和Ccircle,它们都具有IShape界面。相应的类图关系如图5-11所示。
已知某第三方库已经提供了XCircle类,且完全满足CCircle图元显示时所需的功能。【Visual Basic代码6-1】是抽象类IShape类模块内容。【Visual Basic代码6-2】实现了类CCircle的IShape界面,并使用了XCircle提供的显示功能。
XCircle提供的显示功能方法接口为displayIt。
【Visual Basic代码6-1】
Publie Color As Long
Sub draw()
'方法体不包括可执行语句
End Sub
Sub move(stepx As Single, stepy As Single)
'方法体不包括可执行语句
End Sub
【Visual Basic代码6-2】
(1)
Private color As Long
… '其他定义省略
Private ridged As (2)
Private Sub Class_Initialize()
Set bridged=(3)
End Sub
Private Property (4) ()As Long
IShape_Color=color
End Property
Private Property (5) (ByVal newColor As Long)
Color=newColor
End Property
Private Sub IShape_draw() 使用XCircle提供的显示功能
(6)
End Sub
Private Sub IShape_move(stepx As Single, stepy As Single)
… '省略描述
End Sub
第7题
阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。
【说明】
已知窗体上有两个名为cmdGene和cmdSort的命令按钮。单击cmdCene按钮时,随机产生10个[1,100]范围内的整数并将它们放在数组intA中;单击cmdSort按钮时,用选择法排序这10个数并输出。
【程序代码】
Dim intA(1 To 10)As integer
Private Sub cmdGene_Click()
Dim intl As Integer
Randomize
For intl = 1 To 10
intA(intl) =(1)
Next intl
End Sub
Private Sub cmdSort_Click()
Dim intl, intJ,intMin, intTemp As Integer
For intl = 1 To 9
intMin = intA(intl)
For intJ=(2) To 10
If intA(intJ) < intMin Then
Temp = intA(intJ)
intA(intJ)=(3)
intMin = intTemp
End If
Next intJ
(4)
(5)
For intl = 1 To 10
Print Str(intA(intl))+" ";
Next intl
Next lntl
End Sub
第8题
阅读以下说明及Visual Basic程序代码,将应填入(n)上处的字句写在对应栏内。
[说明]
字符组合:程序界面如图示,在文本框Text1中输入若干个任意字符,单击“颠倒”按钮,将这些字符按相反的顺序显示在标签Lable1 中,并在标签Labs1 2处显示字符的个数。例如:输入abcabc2,显示为 2cbabca,组成字符数为4。
[Visual Basic 代码]
Private Sub cmdshow_ Click (
Dim n As Integer
Dim I As Integer
Dim str1 As String
N=Len (Text1.Text )
For I=n To Step- 1
Str1=(1)
Next I
Labe11. Caption=Str1
End Sub
Private Sub cmdcount_ Click ()
Dim n As Integer
Dim in As Integer
Dim i As Integer
Dim j As Integer
Dim flag As Integer
Dim str1 As Integer
Dim str2 As Integer
N=(2)
Str1 =Mid$ (Text1.Text, i. 1
For I =2 To n
Str2=mid$ (Text1,Text,I,1
M=Len (str1)
(3)
For j=1 To m
If (4) Then flag= 1; Exit For
Next j
If flag<>1 then str1=str1& str2
Next I
Lable2.Caption=(5)
End Sub
第9题
●试题七
阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
已知窗体上有两个名为cmdGene和cmdSort的命令按钮。单击cmdGene按钮时,随机产生10个[1,100]范围内的整数并将它们放在数组intA中;单击cmdSort按钮时,用选择法排序这10个数并输出。
【程序代码】
Dim intA(1 To 10)As Integer
Private Sub cmdGene_Click()
Dim intI As Integer
Randomize
For intI=1 To 10
intA(intI)= (1)
Next intI
End Sub
Private Sub cmdSort_Click()
Dim intI,intJ,intMin,intTemp As Integer
For intI=1 To 9
intMin=intA(intI)
For intJ= (2) To 10
If intA(intJ)<intMin Then
Temp=intA(intJ)
intA(intJ)= (3)
intMin=intTemp
End If
Next intJ
(4)
(5)
For intI=1 To 10
Print Str(intA(intI))+" ";
Next intI
Next IntI
End Sub
第10题
阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。
【说明8.1】
以下程序的功能是:生成20个200~300之间的随机整数,输出其中能被5整除的数并求出它们的和。
【程序代码8.1】
Private Sub Command1_Click()
For i=1 To 20
x=Int((1)*200+100)
If (2)=0 Then
Print x
S=S+ (3)
End If
Next i
Print"Sum=";S
End Sub
【说明8.2】
程序8.2运行后,单击窗体,则在窗体上显示的内容是:a=(4)和b=(5)。
【程序代码8.2】
Private Sub Form_Click()
Dim a As Integer,b As Integer
a=20:b=50
p1 a,b
p2 a,b
p3 a,b
Print"a=";a,"b=";b
End Sub
Sub p1(x As Integer, ByValy As Integer)
x=x+l0
y=y+20
End Sub
Sub p2(ByVal×As Integer, y As Integer)
x=x+l0
y=y+20
End Sub
Sub p3(ByVal×As Integer, ByVal y As Integer)
x=x+10
y=y+20
End Sub
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!