2022年二级VB程序设计题库 .pdf
《2022年二级VB程序设计题库 .pdf》由会员分享,可在线阅读,更多相关《2022年二级VB程序设计题库 .pdf(24页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、题号1.判断是不是素数2.汉字的字幕滚动(祝你考试成功) 3 拨号盘4.字幕放大5.画板6.调色板7.复制黏贴8.改变圆大小9.添加删除10.密码检测11.健康称12.最大化13.居中斜体设置14.字符排序15.滚动条数字移动16.替换17.反弹球18.框架19.图片欣赏20.字体设置21.单选按钮日期22.复制选框点餐23.连表框过滤24.字幕闪烁25.滚动条改变字号26.单选按钮倒计时27.坐标系28.连表迁移30.新旧密码31.电子钟32.文本框计算成绩33.偶数迁移35.文本框计算商品36.加法器1.判断是不是素数Private Sub Command1_Click() x = Val
2、(Text1.Text) For i = 2 To x - 1 If x Mod i = 0 Then Exit For Next If i x - 1 Then Label3.Caption = Text1.Text & 是素数 Else Label3.Caption = Text1.Text & 不是素数 End If End Sub Private Sub Form_Load() End Sub 2.汉字的字幕滚动Private Sub Command1_Click() If Command1.Caption = 开始 Then Command1.Caption = 结束 Timer1.
3、Enabled = True Else Command1.Caption = 开始 Timer1.Enabled = False End If End Sub Private Sub Form_Load() Timer1.Enabled = False Label1.AutoSize = True Label1.Alignment = 2 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 24 页 - - - - - - - - - Timer1.Interval = 10
4、0 End Sub Private Sub Timer1_Timer() Label1.Left = Label1.Left + 100 If Label1.Left = Form1.Width Then Label1.Left = -Label1.Width End If End Sub 3 拨号器Dim a As String Private Sub Command1_Click(Index As Integer) Text1.Text = Text1.Text & Command1(Index).Index a = Text1.Text End Sub Private Sub Comma
5、nd2_Click() Text1.Text = Timer1.Enabled = True End Sub Private Sub Form_Load() Timer1.Enabled = False End Sub Private Sub Timer1_Timer() Static i As Integer i = i + 1 b = Mid(a, i, 1) If i Len(a) Then Timer1.Enabled = False i = 0 Else Text1.Text = Text1.Text & b End If End Sub 4.字幕放大Private Sub Comm
6、and1_Click() If Command1.Caption = 开始 Then Command1.Caption = 结束 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 24 页 - - - - - - - - - Timer1.Enabled = True Else Command1.Caption = 开始 Timer1.Enabled = False End If End Sub Private Sub Form_Load() Timer1.Enabled
7、= False Label1.AutoSize = True Label1.Alignment = 2 Timer1.Interval = 200 End Sub Private Sub Timer1_Timer() Label1.FontSize = Label1.FontSize + 2 End Sub 5.画板Picture1.Cls End Sub Private Sub Form_Load() End Sub Private Sub Option1_Click() Picture1.DrawWidth = 1 End Sub Private Sub Option2_Click() P
8、icture1.DrawWidth = 5 End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 24 页 - - - - - - - - - Picture1.PSet (X, Y), CommonDialog1.Color Print
9、Picture1.CurrentX, Picture1.CurrentY End If End Sub 6.调色板Private Sub Command1_Click() Label2.ForeColor = Shape1.FillColor End Sub Private Sub Form_Load() End Sub Private Sub HScroll1_Scroll(Index As Integer) Shape1.FillColor = RGB(HScroll1(0).Value, HScroll1(1).Value, HScroll1(2).Value) End Sub 7.复制
10、黏贴Option Explicit Private Sub Command1_Click() Clipboard.SetText Text1.SelText End Sub Private Sub Command2_Click() Clipboard.Clear Clipboard.SetText Text1.SelText Text1.SelText = End Sub Private Sub Command3_Click() Text1.SelText = Clipboard.GetText() End Sub Private Sub Command4_Click() Text1.SelT
11、ext = End Sub Private Sub Form_Load() End Sub 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 24 页 - - - - - - - - - 8.改变圆大小Private Sub Form_Load() Shape1.Width = 3400 Shape1.Height = 3400 Shape1.Left = 500 Shape1.Top = 500 Label2.Caption = 3400 HScroll1.Value =
12、 3400 End Sub Private Sub HScroll1_Change() Call HScroll1_Scroll End Sub Private Sub HScroll1_Scroll() Shape1.Width = HScroll1 Shape1.Height = HScroll1 Shape1.Left = 2200 - HScroll1.Value / 2 Shape1.Top = 2200 - HScroll1.Value / 2 Label2.Caption = HScroll1.Value End Sub 9.添加删除Private Sub Command1_Cl
13、ick() If Text1.Text = Then MsgBox 没有内容,不予添加 Else List1.AddItem Text1.Text, 0 For i = List1.ListCount To 1 Step -1 List1.List(i) = List1.List(i - 1) Next List1.List(0) = Text1.Text Text1.Text = End If Text1.SetFocus End Sub Private Sub Command2_Click() If List1.ListIndex = -1 Then MsgBox 请选择要删除的项目 El
14、se List1.RemoveItem List1.ListIndex 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 24 页 - - - - - - - - - End If End Sub Private Sub Form_Load() End Sub 10.密码检测Private Sub Form_Load() End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Static times As Integ
15、er If KeyAscii = 13 Then If Text1.Text = 1234567 Then Label2.Caption = 欢迎关临 Else times = times + 1 If times = 1 Then Label2.Caption = 密码不符,请再输入一遍 Text1.Text = Else Label2.Caption = 非法用户,请退出 Text1.Enabled = False End If End If End If End Sub 11.健康称Private Sub Command1_Click() Select Case (Text2.Text)
16、 / Val(Text1.Text - 105) Case Is 1.1 Label5.Caption = 偏胖,注意节食 Case Is = 0.9 Label5.Caption = 正常 Case Else Label5.Caption = 偏瘦,增加营养 End Select End Sub Private Sub Form_Load() 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 24 页 - - - - - - - - - End Sub Private S
17、ub Text1_KeyPress(KeyAscii As Integer) If KeyAscii 57 Then KeyAscii = 0 End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii 57 Then KeyAscii = 0 End Sub 12.最大化Private Sub cmdmaxsize_Click() If cmdmaxsize.Caption = 最大化 (&L) Then design10 最大化 .WindowState = 2 cmdmaxsize.Caption = 还原 (&
18、B) Else design10 最大化 .WindowState = 0 cmdmaxsize.Caption = 最大化 (&L) End If cmdmaxsize.Left = (design10 最大化 .Width - cmdmaxsize.Width) / 2 cmdmaxsize.Top = (design10 最大化 .Height - cmdmaxsize.Height) / 2 End Sub Private Sub Form_Load() cmdmaxsize.Left = (design10 最大化 .Width - cmdmaxsize.Width) / 2 cmd
19、maxsize.Top = (design10 最大化 .Height - cmdmaxsize.Height) / 2 End Sub 13.居中斜体设置Text1.FontItalic = False Case 斜体 Text1.FontBold = False Text1.FontItalic = True Case 粗体 Text1.FontBold = True Text1.FontItalic = False Case 粗斜体 Text1.FontBold = True Text1.FontItalic = True 名师资料总结 - - -精品资料欢迎下载 - - - - - -
20、 - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 24 页 - - - - - - - - - End Select End Sub Private Sub Form_Load() Combo1.AddItem 左对齐 Combo1.AddItem 居中 Combo1.AddItem 右对齐 Combo2.AddItem 常规 Combo2.AddItem 斜体 Combo2.AddItem 粗体 Combo2.AddItem 粗斜体 End Sub 14.字符排序Dim x() As String * 1 Private Sub Co
21、mmand1_Click() m = Len(Text1.Text) ReDim x(m) As String * 1 For i = 1 To m x(i) = Mid(Text1.Text, i, 1) Next For i = 1 To m - 1 For j = i + 1 To m If x(i) x(j) Then a = x(i): x(i) = x(j): x(j) = a Next Next For i = 1 To m Print x(i); Next Command1.Enabled = False End Sub Private Sub Form_Load() End
22、Sub 15.滚动条字移动Private Sub Command1_Click() End End Sub 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 24 页 - - - - - - - - - Private Sub Form_Load() HScroll1.Max = Width / 2 HScroll1.Min = 0 End Sub Private Sub HScroll1_Change() Call HScroll1_Scroll End Sub Priv
23、ate Sub HScroll1_Scroll() Label1.Left = HScroll1.Value End Sub 16.替换Private Sub Command3_Click() For i = 1 To Len(Text1.Text) - 1 If Text2.Text = Mid(Text1.Text, i, Len(Text2.Text) Then Text1.SelStart = i Text1.SelLength = Len(Text2.Text) Exit For End If Next If i Len(Text1.Text) - 1 Then MsgBox 没找到
24、! Else Text1.SelText = Text3.Text End If End Sub Private Sub Form_Load() End Sub 17.反弹球Private Sub Form_Load() Timer1.Enabled = False x = 200 y = 200 End Sub Private Sub mnu_b_Click() x1 = Shape1.Left y1 = Shape1.Top 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页
25、,共 24 页 - - - - - - - - - Timer1.Enabled = True Timer1.Interval = 100 End Sub Private Sub mnu_s_Click() Timer1.Enabled = False End Sub Private Sub Timer1_Timer() x2 = x1 + x y2 = y1 + y Dim k As Long If x2 + Shape1.Width Me.ScaleWidth Then k = Me.ScaleWidth - Shape1.Left - Shape1.Width x = -200 If y
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年二级VB程序设计题库 2022 二级 VB 程序设计 题库
限制150内