(完整版)浙江省高校计算机等级考试复习资料——二级VB语言(答案)

loading 分享 2026-9-4 下载文档

12. 新建一个工程,完成应用程序的设计。具体要求如下: 参考答案:

Private Sub Command1_Click() End End Sub

Private Sub Form_Load() Command1.Caption = \结束\End Sub

Private Sub Option1_Click() If Option1.Value = True Then

Text1.Text = \今天是\

End If

End Sub

Private Sub Option2_Click() If Option2.Value = True Then

Text1.Text = \今天是\年\End If End Sub

Private Sub Option3_Click() If Option3.Value = True Then

Text1.Text = \今天是\月\End If End Sub

Private Sub Option4_Click() If Option4.Value = True Then

Text1.Text = \今天是\日\End If End Sub

13. 新建一个工程,完成“字体修饰” 程序的设计。具体要求如下: 参考答案:

Private Sub Check1_Click(Index As Integer) If Check1(0).Value = 1 Then Label1.FontBold = True

Else

Label1.FontBold = False End If

If Check1(1).Value = 1 Then Label1.FontItalic = True Else

Label1.FontItalic = False End If End Sub

Private Sub Option1_Click(Index As Integer) If Option1(0).Value = True Then Label1.FontName = \宋体\Else

Label1.FontName = \楷体_GB2312\End If End Sub

14. 新建一个工程,完成“点餐”程序的设计。具体要求如下:

参考答案:

Private Sub Check1_Click(Index As Integer)

If Check1(Index).Value Then '若当前复选框被选中,文本框被启用,同时获得焦点 Text1(Index).Enabled = True Text1(Index).SetFocus End If End Sub

Private Sub Command1_Click() Dim a%, b%, c%, sum% If Check1(0).Value Then a = Val(Text1(0).Text) End If

If Check1(1).Value Then b = Val(Text1(1).Text) End If

If Check1(2).Value Then c = Val(Text1(2).Text) End If

sum = a * 13 + b * 18 + c * 25

MsgBox \一共\元\总价\End Sub

Private Sub Form_Load() Form1.Caption = \点餐\

Form1.BorderStyle = 1 Command1.Caption = \确定\Frame1.Caption = \菜单\

Check1(0).Caption = \儿童套餐馆13元\Check1(1).Caption = \标准套餐18元\Check1(2).Caption = \商务餐25元\Label1(0).Caption = \份数\Label1(1).Caption = \份数\Label1(2).Caption = \份数\Check1(0).Value = 0 Check1(1).Value = 0 Check1(2).Value = 0

Text1(0).Enabled = False Text1(1).Enabled = False Text1(2).Enabled = False End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then '输入非数字 KeyAscii=0 End If End Sub

15. 新建一个工程,完成应用程序的设计。具体要求如下: 参考答案:

Private Sub Check1_Click() If Check1.Value = 0 Then

Combo1.Enabled = False Text1.Enabled = False Else

Combo1.Enabled = True Text1.Enabled = True End If End Sub

Private Sub Check2_Click() If Check2.Value = 0 Then

Option1.Enabled = False Option2.Enabled = False Else

Option1.Enabled = True

Option2.Enabled = True End If End Sub

Private Sub Command1_Click() If Check1.Value = 1 Then

Label3.Caption = Combo1.Text & Text1.Text End If

If Check2.Value = 1 Then If Option1.Value = 1 Then

Label3.Caption = Label3.Caption & Option1.Caption End If

If Option2.Value = 1 Then

Label3.Caption = Label3.Caption & Option2.Caption End If

End If End Sub

Private Sub Form_Load() Check1.Value = 0 Combo1.Enabled = 0 Text1.Enabled = 0 Check2.Value = 0 Option1.Enabled = 0 Option2.Enabled = 0 End Sub

16. 新建一个工程,完成“改变字号”程序的设计。具体要求如下:

参考答案:

Private Sub Form_Load()

Form1.Caption = \改变字号\End Sub

Private Sub HScroll1_Change() Text1.Text = HScroll1.Value

Label1.FontSize = HScroll1.Value

Label1.Left=Form1.Width/2 - Label1.Width/2 '使用标签在窗体水平居中 End Sub

Private Sub HScroll1_Scroll() Call HScroll1_Change End Sub

Private Sub Text1_Change() Dim i As Integer i = Val(Text1.Text)

If i >= 12 And i <= 72 Then Label1.FontSize = i HScroll1.Value = i End If End Sub

17. 新建一个工程,完成应用程序的设计。具体要求如下: 参考答案:

Private Sub Form_Load()

Label1.Caption = \欢迎您的使用\HScroll1.Value = Label1.Left HScroll1.Min = 0

HScroll1.Max = Form1.ScaleWidth - Label1.Width End Sub

Private Sub HScroll1_Change() Label1.Left = HScroll1.Value End Sub

Private Sub HScroll1_Scroll() HScroll1_Change End Sub

18. 新建一个工程,完成“调色板”程序的设计具体要求如下: 参考答案:

Private Sub Command1_Click()

Label4.ForeColor = Shape1.FillColor End Sub

Private Sub Form_Load() Dim i%

For i = 0 To 2

HScroll1(i).Max = 255 HScroll1(i).Min = 0 Next i

Shape1.FillStyle = 0

Shape1.BorderColor = vbBlack End Sub

Private Sub HScroll1_Change(Index As Integer)


(完整版)浙江省高校计算机等级考试复习资料——二级VB语言(答案).doc 将本文的Word文档下载到电脑
搜索更多关于: (完整版)浙江省高校计算机等级考试复习资料——二级VB语言( 的文档
相关推荐
相关阅读