A1
Private Sub Command1_Click()
  Label3 = Text1
End Sub
A2
Private Sub Form_Load()
    Timer1.Interval = 0
End Sub
Private Sub Command1_Click()  '自动
    Timer1.Interval = 200
End Sub
Private Sub Command2_Click()  '手动
  Timer1.Interval = 0
  Call MyMove
End Sub
Private Sub Timer1_Timer()
    Call MyMove
End Sub
Sub MyMove()
  Label1.Move Label1.Left - 50
  If Label1.Left < 0 Then Label1.Left = Form1.Width
End Sub
A3
Private Sub Form_Click()
  Text1 = Val(Text1) + 1
End Sub
Private Sub Form_Load()
  Text1 = 0
End Sub
A4
Private Sub Form_Click()
  Caption = "单击窗体,改变图片"
  Picture = LoadPicture(App.Path + "\n_015.bmp")
  Print "欢迎使用VB"
End Sub
Private Sub Form_DblClick()
  Cls
  Caption = "双击窗体,卸去图片"
  Picture = LoadPicture("")  '
End Sub
Private Sub Form_Load()
  Caption = "装入窗体"
  Picture = LoadPicture(App.Path + "\n_016.bmp")
  Print "装入图"
End Sub
Private Sub Form_Resize()    ' 该事件的作用窗体始终与图一样大
  'Caption = "窗体大小不变"
  'Form1.Width = 260 * 16      ' 260Tongji-2.bmp图的宽度,象素单位
  'Form1.Height = 260 * 16 + 200  ' 260是图的高度,象素单位,200是窗体的标题栏高度
End Sub
A5
Sub Command1_Click()
  Text1.FontName = "隶书"
  Text1.FontSize = 25
End Sub
Sub Command2_Click()
  Text2.Text = Text1.SelText
  Text2.FontName = Text1.FontName
  Text2.FontSize = Text1.FontSize
End Sub
B1
Private Sub Command1_Click()
Text2 = Format(5 / 9 * (Val(Text1) - 32), "0.00")
End Sub
Private Sub Command2_Click()
  Text1 = Format(9 / 5 * Val(Text2) + 32, "0.00")
End Sub
Private Sub Command1_Click()
  Dim f!, c!                  ' 声明两个变量
  f = Val(Text1)
  c = 5 / 9 * (f - 32)
  Text2 = Format(c, "0.00")  ' 保留两位小数
End Sub
Private Sub Command2_Click()
  Dim ff!, cc!                  ' 声明两个变量
  cc = Val(Text2)
  ff = 9 / 5 * cc + 32
  Text1 = Format(ff, "0.00")  ' 保留两位小数
End Sub
B2
Private Sub Command1_Click()
Label2 = Format(Val(Text1) * Val(Text1) * 3.14, "0.00")
End Sub
Private Sub Command2_Click()
  Label3 = Format(Val(Text1) * 3.14 * 2, "0.00")
End Sub
Private Sub Text1_LostFocus()
  If Not IsNumeric(Text1.Text) Then
    MsgBox "输入有非数字字符,请重新输入", , "警告"
    Text1.Text = ""
vb语言程序设计第五版上机答案    Text1.SetFocus
  End If
End Sub
Private Sub Command1_Click()
Label2 = Format(Val(Text1) * Val(Text1) * 3.14, "0.00")
End Sub
Private Sub Command2_Click()
  Label3 = Format(Val(Text1) * 3.14 * 2, "0.00")
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    If Not IsNumeric(Text1.Text) Then
    Text1.Text = ""
    End If
  End If
End Sub
B3
Private Sub Command1_Click()
  n = Int(Log(2) / Log(1.008) + 1)
  Label1 = n & "年后人数超过26亿"
End Sub
B4
Private Sub Command1_Click()
  Dim x, dx, cd
  x = Text1.Text
  dx = UCase(x)
  cd = Len(x)
  Print "大写字母为:"; dx
  Print "字符串长度为:"; cd
End Sub
B5
Private Sub Command1_Click()
  Text1 = Int(Rnd * 900 + 100)
End Sub
Private Sub Command2_Click()
  Dim x%, x1%, x2%, x3%
  x = Val(Text1)
  x1 = x Mod 10                  ' 分离出的个位数
  x2 = (x Mod 100) \ 10          ' 分离出的十位数
  x3 = x \ 100                    ' 分离出的百位数
  Label1 = x1 * 100 + x2 * 10 + x3
End Sub
B6
Private Sub Form_Click()
Label1 = Left(Text1, 11)
  Label2 = Mid(Text1, 12, 6)
  Label3 = Right(Text1, 5)
End Sub
B7
Private Sub Command1_Click()
  Print
  For i = 1 To 5
    Print Tab(15 - i * 2); String(2 * i - 1, ""); Spc(18 - 4 * (i - 1)); String(2 * i - 1, "")
  Next i
End Sub
Private Sub Command2_Click()
  Cls
End Sub
进一步要求:
Private Sub Command1_Click()
  Print
  For i = 1 To 5
    Print Tab(15 - i * 2); String(2 * i - 1, ""); String(10 - (2 * i - 1), ""); String(2 * i - 1, "")
  Next i
End Sub
Private Sub Command2_Click()
  Cls
End Sub
B8
Private Sub Form_Click()
x = Val(InputBox("输入一正实数", "计算", 0))
pf = Format(x * x, "0.000")
pfg = Format(Sqr(x), "0.000")
lf = Format(x * x * x, "0.000")
lfg = Format(x ^ (1 / 3), "0.000")
Print "平方为:"; pf; Space(5); "平方根为:"; pfg; Space(5); "立方为:"; lf; Space(5); "立方根为:"; lfg
End Sub
C1
Private Sub Form_Click()
Dim x!, y!
x = Val(InputBox("输入x的值"))
If x < 1000 Then
y = x
ElseIf x < 2000 Then
y = 0.9 * x
ElseIf x < 3000 Then
y = 0.8 * x
Else
y = 0.7 * x
End If
Print y
End Sub
C2
Private Sub Form_Click()
Dim x!, y!
x = Val(InputBox("输入上网时间"))
If x < 10 Then
y = 30
ElseIf x < 50 Then
y = 30 + 2.5 * (x - 10)
Else

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。