我想要用VB做一个模仿心电图的程序,要求:
1.黑色背景+绿色网格
2.带心跳数
3.线条不是相同的,忽高忽低。
希望上面几点可以做到~~~
我想要用VB做一个模仿心电图的程序,要求:
1.黑色背景+绿色网格
2.带心跳数
3.线条不是相同的,忽高忽低。
希望上面几点可以做到~~~
新建一个工程,无需添加任何控件,直接将原程序复制即可,后面的Rnd为随机参数,可以自己修改。点击可以暂停,再次点击恢复。
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private WithEvents Timer1 As Timer
Private WithEvents Picture1 As PictureBox
Private Sub Form_Load()
Set Timer1 = Controls.Add("VB.Timer", "Timer1")
Set Picture1 = Controls.Add("VB.PictureBox", "Picture1")
BorderStyle = 0: Caption = ""
Move Screen.Width / 2 - 4000, Screen.Height / 2 - 2000, 8000, 4000
Timer1_Timer: Timer1.Interval = 20
Picture1.AutoRedraw = True: Picture1.BackColor = vbbladck:
Picture1.ForeColor = vbGreen
Picture1.Move 120, 120, 7760, 3760
Picture1.Scale (0, 100)-(200, -100)
Picture1.Visible = True
End Sub
Private Sub Picture1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then End
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then ReleaseCapture: SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Timer1_Timer()
Randomize
Static Xy!(200), Er!: Dim i!, j!
Er = Er + 1: If Er = 21 Then Er = 1
Select Case Er
Case 1 To 5
Xy(200) = Sin(Er) * 5 + Rnd * 10
Case 6 To 13
Xy(200) = Choose(Er - 5, -25, 25, 50, 25, 0, 0, 0, 0) + Rnd * 50 - 25
Case 14 To 20
Xy(200) = Sin(Er) + Rnd * 10
End Select
Picture1.Cls
For i = 10 To 200 Step 20
Picture1.Line (i, 100)-(i, -100), RGB(0, 150, 0)
Picture1.Line (0, i - 100)-(200, i - 100), RGB(0, 150, 0)
Next
For i = 1 To 200
Picture1.Line (i - 1, Xy(i - 1))-(i, Xy(i))
Next
For i = 0 To 199
Xy(i) = Xy(i + 1)
Next
End Sub