vb课后习题答案
- 格式:docx
- 大小:18.25 KB
- 文档页数:18
A2 Public Class SyA_2
Private Sub SyA_2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
MsgBox("欢迎您使用!")
End Sub
End Class
A3 Public Class SyA_3
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Label3.Text = TextBox1.Text
End Sub
End Class
A4 Public Class SyA_4
Dim x As Integer, y As Integer, k As Integer
Dim flag As Boolean = True
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
x = 250 : y = 250
Label7.Location = New Point(x - 100, y + 110)
PictureBox1.Location = New Point(x, y)
Timer1.Interval = 10
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label6.Text = Label7.Left
If flag = True Then
y -= 1
Label7.Location = New Point(x - 100, y + 110)
PictureBox1.Location = New Point(x, y)
Label3.Text = "上"
Label7.BackColor = Color.Blue
Label7.ForeColor = Color.FloralWhite
If (Integer.Parse(Label5.Left) <= 0) Then
flag = False
End If
Else
y += 1
Label7.Location = New Point(x - 100, y + 110)
PictureBox1.Location = New Point(x, y)
Label3.Text = "下"
Label7.BackColor = Color.FloralWhite
Label7.ForeColor = Color.Blue
If (Integer.Parse(Label7.Top) + Integer.Parse(Label7.Height) >= Integer.Parse(Me.Width)) Then
flag = True
End If
End If
End Sub
End Class
A5 Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
TextBox1.Text = Val(TextBox1.Text) + 1
End Sub
A6 Public Class SyA_6
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = TextBox1.Text ^ TextBox2.Text
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox3.Text = TextBox1.Text ^ TextBox2.Text Then TextBox3.Text = "正确" Else TextBox3.Text = "错误"
End Sub
End Class
B1 Module Module1
Sub Main()
Dim a AsBoolean
Dim b AsBoolean
a = True
b = False
Console.WriteLine("{0} {1} {2} {3}", "a", True, "b", False) Console.WriteLine("{0} {1} {2} {3} {4}", a, "AND", b, "为a", a And b) Console.WriteLine("{0} {1} {2} {3} {4} {5}", a, "AND", "Not", b, "为a", a AndNot b)
Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} ", a, ">", b, "OR", b, "为a", a > b Or b)
Console.ReadLine()
EndSub
End Module