VisualBasic程序设计—实验报告册-参考答案

Private Sub Command1_Click() Text2 = Text1 End Sub

Private Sub Command2_Click() Text1 = \Text2 = \End Sub

Private Sub Form_Load() Command1.Visible = False Command2.Visible = False End Sub

Private Sub Text1_Change() Command1.Visible = True Command2.Visible = True End Sub

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3300 ClientLeft = 60 ClientTop = 450 ClientWidth = 4695 BeginProperty Font

Name = \宋体\ Size = 12 Charset = 134 Weight = 700

Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty

LinkTopic = \ ScaleHeight = 3300 ScaleWidth = 4695

StartUpPosition = 3 '窗口缺省 Begin VB.Timer Timer1

Enabled = 0 'False Interval = 500 Left = 3120 Top = 1320 End

Begin VB.CommandButton Command2 Caption = \停止\ Height = 495 Left = 2640 TabIndex = 1 Top = 2400 Width = 975 End

Begin VB.CommandButton Command1 Caption = \移动\ Height = 495 Left = 840 TabIndex = 0 Top = 2400 Width = 1095 End

Begin VB.Image Image1

Height = 1800 Left = 840 Top = 360 Width = 1500 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load()

Image1.Picture = LoadPicture(\End Sub

Private Sub Command1_Click() Timer1.Enabled = True End Sub

Private Sub Command2_Click() Timer1.Enabled = False End Sub

Private Sub Timer1_Timer()

Image1.Left = Int(Rnd * (Form1.ScaleWidth - Image1.Width)) Image1.Top = Int(Rnd * (Form1.ScaleHeight - Image1.Height))

End Sub

实验3

VERSION 5.00

Begin VB.Form Form1

Caption = \ ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = \ ScaleHeight = 3195 ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = \ Height = 495 Left = 3720 TabIndex = 0 Top = 2640 Width = 855 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click()

Print 2 * 3 ^ 2 * 8 / 4 + 3 ^ 2 Print Sqr(Sqr(64)) Print #2/27/2004# - 10 Print Int(-3.1415926)

Print Int(Abs(99 - 100) / 2) Print Fix(-3.1415926) Print Int(-3.5), Int(3.5) Print Fix(3.5), Fix(3.5) Print Sgn(7 * 3 + 2) Print LCase(\ Print Val(\ Print Str(-459.65)

Print Len(\程序设计 ok\ Print \

Print 123 + Mid(\

Print 123 & Mid(\ Print DateAdd(\End Sub

Caption = \ ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 6825 BeginProperty Font

Name = \宋体\ Size = 15 Charset = 134 Weight = 700

Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty

LinkTopic = \ ScaleHeight = 3195 ScaleWidth = 6825

StartUpPosition = 3 '窗口缺省 Begin VB.TextBox Text1 Height = 495 Left = 3120 TabIndex = 2

Text = \ Top = 240 Width = 1695 End

Begin VB.CommandButton Command1

Caption = \计算平方立方(根)\ BeginProperty Font

Name = \宋体\ Size = 14.25 Charset = 134 Weight = 700

Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty

Height = 495 Left = 1680 TabIndex = 0 Top = 960

Width = 3015 End

Begin VB.Label Label2

Caption = \ Height = 735 Left = 480 TabIndex = 3 Top = 1920 Width = 5895 End

Begin VB.Label Label1

Caption = \输入一个数\ Height = 495 Left = 1320 TabIndex = 1 Top = 240 Width = 1935 End End

Attribute VB_Name = \

Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim n%

n = Abs(Val(Text1))

Label2 = Format(n ^ 2, \& Space(2) & Format(n ^ 3, \\End Sub

Begin VB.Form Form1

Caption = \ ClientHeight = 3330 ClientLeft = 60 ClientTop = 345 ClientWidth = 5985 LinkTopic = \ ScaleHeight = 3330 ScaleWidth = 5985

StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command2 Caption = \方法二\

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4