找回密码
 注册
Simdroid-非首页
查看: 221|回复: 3

【已应助,谢谢大家】一个较难的VB程序

[复制链接]
tsl1980 该用户已被删除
发表于 2006-7-25 21:26:14 | 显示全部楼层 |阅读模式 来自 江苏南京
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2006-7-26 03:03:52 | 显示全部楼层 来自 加拿大
Simdroid开发平台
在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
发表于 2006-7-26 16:08:20 | 显示全部楼层 来自 广西桂林
把楼上的程序翻译一下
Private temp As Integer
Private timeCount As Integer
Private disp As Double

Private Sub btnMal_Click()
    timerMal.Enabled = True
End Sub

Private Sub Form_Load()
    timeCount = 0
End Sub

Private Sub timerMal_Timer()
    timeCount = timeCount + 1
    temp = 25 + timeCount
    disp = timeCount * 0.1
    labShow.Caption = "Temperature: " & temp & ", " & "Displacement: " & disp
    If temp > 60 Or disp > 5 Then
        Beep
    End If
    If temp > 100 Or disp > 12 Then
        Beep
        labShow.Caption = "Exploding..."
        timerMal.Enabled = False
    End If
End Sub

Private Sub btnStop_Click()
    timerMal.Enabled = False
    timeCount = 0
    temp = 0
    disp = 0
    labShow.Caption = "Temperature: 25, Displacement: 0"
End Sub
tsl1980 该用户已被删除
 楼主| 发表于 2006-7-26 22:43:21 | 显示全部楼层 来自 江苏南京
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-11-1 21:29 , Processed in 0.032648 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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