教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

《Visual Basic程序设计基础》习题参考答案(4)

来源:网络收集 时间:2026-05-15
导读: If Text1.Text = pwd Then m = MsgBox(\口令正确,欢迎进入!\ Else m = MsgBox(\口令错误,请重新输入!\ End If End If End Sub 程序4.界面设计略,过程设计如下: Dim num As Integer, m As Integer, rec As Int

If Text1.Text = pwd Then

m = MsgBox(\口令正确,欢迎进入!\ Else

m = MsgBox(\口令错误,请重新输入!\ End If End If End Sub

程序4.界面设计略,过程设计如下:

Dim num As Integer, m As Integer, rec As Integer Private Sub Form_Load()

Command1.Caption = \出题\ Text1.Text = \End Sub

Private Sub Command1_Click()

Randomize: num = Int(Rnd * 100) + 1: Text1.Enabled = True Label1.Caption = \End Sub

Private Sub Command2_Click() End End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

m = Val(Text1.Text): rec = rec + 1: Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text): Text1.SetFocus If rec > 10 Then

Label1.Caption = \差!重新开始\ Else

If m > num Then

Label1.Caption = Str(m) & \大了!\ ElseIf m < num Then

Label1.Caption = Str(m) & \小了!\ Else

If rec < 5 Then

Label1.Caption = \好!猜对了。\ Else

Label1.Caption = \还行!猜对了。\ End If

Call Form_Load

End If End If End If End Sub

程序5.界面设计如图10-3所示,过程设计如下: Private Sub Form_Load()

Command1(0).Enabled = False: Command1(1).Enabled = False Command1(2).Enabled = False: Label1.Caption = \End Sub

Private Sub Command1_Click(Index As Integer) Select Case Index Case 0

Clipboard.Clear: Clipboard.SetText Text1.SelText

Text1.SelText = \请选择要粘贴的位置!\ Command1(0).Enabled = False: Command1(1).Enabled = False Command1(2).Enabled = True Case 1

Clipboard.Clear: Clipboard.SetText Text1.SelText

Label1.Caption = \请选择要粘贴的位置!\Command1(0).Enabled = False Command1(1).Enabled = False: Command1(2).Enabled = True Case Else

Text1.SelText = Clipboard.GetText(): Form_Load Label1.Caption = \粘贴完成!\ End Select End Sub

Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, _

X As Single, Y As Single) Dim n As Integer n = Text1.SelLength If n > 0 Then

Label1.Caption = \选择了\个字,请选择下一步操作!\ Command1(0).Enabled = True: Command1(1).Enabled = True Else

Label1.Caption = \ End If End Sub

程序6.界面设计如图10-4所示,过程设计如下: Private Sub Form_Load()

Label1.Caption = \当前日期:\

Option1(0).Caption = \显示日期\显示时间\ Option1(0).Value = True: Command1.Caption = \退出\End Sub

Private Sub Option1_Click(Index As Integer) Select Case Index Case 0

Label1.Caption = \当前日期:\ Case 1

Label1.Caption = \当前时间:\ End Select End Sub

Private Sub Command1_Click() End End Sub

程序7.过程设计如下: Private Sub Form_Load()

Label1.Caption = \当前日期:\

Option1(0).Caption = \显示日期\显示时间\ Option1(0).Value = True: Command1.Caption = \退出\ Combo1.AddItem \年-月-日\月-日-年\ Combo1.AddItem \日-月-年\年-月-日\End Sub

Private Sub Combo1_Click() Dim n As String

Select Case Combo1.ListIndex Case 0: n = \ Case 1: n = \ Case 2: n = \ End Select

Text1.Text = Format(Date, n) End Sub

Private Sub Option1_Click(Index As Integer) Select Case Index

Case 0: Label1.Caption = \当前日期:\ Case 1: Label1.Caption = \当前时间:\ End Select End Sub

Private Sub Command1_Click() End End Sub

程序8. 界面设计如图10-5所示,过程设计如下: Private Sub Form_Load()

List1.AddItem \ List1.AddItem \End Sub

Private Sub Command1_Click()

List1.AddItem Text1.Text: Text1.SetFocus

Text1.SelStart = 0: Text1.SelLength = Len(Text1.Text) End Sub

Private Sub Command3_Click() List1.Clear End Sub

Private Sub Command4_Click() End End Sub

Private Sub Command2_Click()

If List1.ListIndex <> -1 Then List1.RemoveItem List1.ListIndex End Sub

9.界面设计如图10-6所示,过程设计如下: Private Sub Form_Load()

Option1(0).Caption = \八进制\十六进制\ Option1(2).Caption = \二进制\End Sub

Private Function tran(k As Long, n As Integer) As String Dim x As Integer, y As String * 1, k1 As Long tran = \ Do While k1 > 0 x = k1 Mod n

If x >= 10 Then y = Chr(Asc(\ tran = y + tran k1 = k1 \\ n Loop

If k < 0 Then tran = \End Function

Private Sub Option1_Click(Index As Integer)

Dim k As Long, n As Integer k = Val(Text1.Text) Select Case Index Case 0

Label2.Caption = \八进制\ Case 1

Label2.Caption = \十六进制\ Case 2

Label2.Caption = \二进制\ End Select

Text2.Text = tran(k, n) End Sub

10.界面设计如图10-7所示,过程设计如下: Private Sub Form_Load()

Label1.Left = Width / 2 - Label1.Width / 2 Label1.AutoSize = True

HScroll1.Min = 1: HScroll1.Max = 1000

HScroll1.SmallChange = 10: HScroll1.LargeChange = 100 HScroll1.Value = 500: Timer1.Interval = 500 End Sub

Private Sub HScroll1_Change() Timer1.Interval = HScroll1.Value End Sub

Private Sub HScroll1_Scroll() Call HScroll1_Change End Sub

Private Sub Timer1_Timer()

Label1.FontSize = Label1.FontSize + 2 Label1.Left = Width / 2 - Label1.Width / 2

If Label1.FontSize >= 72 Then Timer1.Enabled = False End Sub

第6章 图形控件和图形方法

一、判断题

1.√ 2.× 3.√ 4.× 5.√ 6.× 7.× 8.× 9.√.√

10

…… 此处隐藏:2322字,全部文档内容请下载后查看。喜欢就下载吧 ……
《Visual Basic程序设计基础》习题参考答案(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/598753.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)