- 积分
- 35
- 注册时间
- 2004-10-14
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2006-7-26 03:03:52
|
显示全部楼层
来自 加拿大
在Visual Basic.Net 2005 Express中调试通过。
使用以下代码时必须:
添加1个Label, 1个Timer控件和2个Button控件,并修改Name属性于代码相符。
Public Class frmMal
Dim temp As Integer
Dim timeCount As Integer
Dim disp As Double
Private Sub btnMal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMal.Click
timerMal.Enabled = True
End Sub
Private Sub timerMal_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerMal.Tick
timeCount += 1
temp = 25 + timeCount
disp = timeCount * 0.1
labShow.Text = "Temperature: " + temp.ToString + ", " + "Displacement: " + disp.ToString
If temp > 60 Or disp > 5 Then
Beep()
End If
If temp > 100 Or disp > 12 Then
Beep()
labShow.Text = "Exploding..."
timerMal.Enabled = False
End If
End Sub
Private Sub frmMal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
timeCount = 0
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
timerMal.Enabled = False
temp = 0
disp = 0
labShow.Text = "Temperature: 25, Displacement: 0"
End Sub
End Class |
|