虚数灵境爱好者乐园

 找回密码
 注册
搜索
查看: 871|回复: 0
收起左侧

VB课后程序设计题代码

[复制链接]
发表于 2010-5-17 19:26:05 | 显示全部楼层 |阅读模式
第一章
1
Private Sub Form_Load()

End Sub
2
Private Sub Command1_Click()
Text3.Text = Text1.Text + Text2.Text
End Sub

Private Sub Form_Load()

End Sub
3
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End Sub

Private Sub Form_Load()

End Sub

第二章
1
Dim a As Long
Dim b As Long
Dim c As Long

Private Sub Command1_Click()

a = Val(Text1.Text) * 3600
b = Val(Text2.Text) * 60
c = Val(Text3.Text)
Text4.Text = a + b + c

End Sub

Private Sub Form_Load()

End Sub
2
Private Sub Command1_Click()

If Val(Text2.Text) = 0 Then
MsgBox "除数不能为0!", vbOK, "输入数据错误"
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If

End Sub

Private Sub Form_Load()

End Sub
3
Private Const I As Double = 3.1415926
Private Sub Command1_Click()
' Const I As Double = 3.1415926
Label2.Caption = Val(Text1.Text) * (180 / I)
End Sub

Private Sub Command2_Click()
End
End Sub


Private Sub Form_Load()

End Sub
第三章
1
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu cd
End If
End Sub
2
Private Sub Command1_Click()
Dim i, j As Integer
For i = 0 To 3
For j = 4 To 7
If Option1(i).Value = True And Option1(j).Value = True Then
MsgBox "你提交的答案是:" + Chr(13) + Option1(i).Caption + Chr(13) + Option1(j).Caption
End If
Next j
Next i
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()

End Sub
3
Private Sub Command1_Click()
Unload Form1
End Sub

Private Sub Form_Load()

End Sub

Private Sub Text1_Change()
Text2.Text = Hex(Val(Text1.Text))
End Sub

4
Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Form_Load()
Text1.Text = Year(Date)
Text2.Text = Month(Date)
Text3.Text = Day(Date)
Timer1.Enabled = True

End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub Timer1_Timer()
Text4.Text = Format(Now, "hh:mm:ss")
End Sub
5
Private Sub Command1_Click()

List1.AddItem (Text1.Text)
Text1.Text = ""
Text1.SetFocus
End Sub


Private Sub Command2_Click()

Dim i, j As Integer
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
For i = 0 To List2.ListCount - 1
For j = i + 1 To List2.ListCount - 1
  If Val(List2.List(i)) > Val(List2.List(j)) Then
     T = List2.List(i)
     List2.List(i) = List2.List(j)
     List2.List(j) = T
  End If
Next j
Next i
End Sub

Private Sub Form_Load()

End Sub


第四章
1
Private Sub Form_Load()

End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{tab}"
End Sub
2
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox "keydown事件发生了,keycode的值是:" & KeyCode & Chr(13) & "shift参数的值是:" & Shift
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
MsgBox "keypress事件发生了,KeyAscii的值是:" & KeyAscii & Chr(13)
End Sub
3
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form1.Circle (X, Y), 60
Form1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
4
Private Sub MyRnd(B() As Integer)

Dim i As Integer
Randomize
For i = 1 To 10
  B(i) = Int(Rnd * 100)
Next i

End Sub

Private Sub Command1_Click()
Dim A(1 To 10) As Integer
Dim i As Integer
MyRnd A
For i = 1 To 10
For j = i + 1 To 10
  If A(i) > A(j) Then
     t = A(i)
     A(i) = A(j)
     A(j) = t
  End If
Next j
Next i
List1.Clear
For i = 1 To 10
  List1.AddItem A(i)
Next i


End Sub

Private Sub Form_Load()

End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

站点统计|小黑屋|手机版|Archiver|南京虚数灵境科技有限责任公司 ( 苏ICP备2023024155号 ) | 公安备案号:32010402000195

GMT+8, 2025-1-7 04:56 , Processed in 1.140625 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表