Private Sub Form_Load()
Dim i As Integer
Randomize
m_OldValue = 50
' Draw on a 1-100 scale vertically and
' a pixel scale horizontally.
picGraph.AutoRedraw = True
picGraph.ScaleMode = vbPixels
picGraph.ScaleTop = 100
picGraph.ScaleHeight = -101
' Draw guidelines.
For i = 20 To 80 Step 20
picGraph.Line (0, i)-(picGraph.ScaleWidth, i), vbRed
Next i
picGraph.Picture = picGraph.Image
End Sub
|
Private Sub tmrGraph_Timer()
Dim new_value As Integer
Dim i As Integer
' Move the old data over.
picGraph.PaintPicture picGraph.Picture, _
0, 1, picGraph.ScaleWidth - m_Dx, 101, _
m_Dx, 1, picGraph.ScaleWidth - m_Dx, 101
' Erase the right edge and draw guide lines.
picGraph.Line (picGraph.ScaleWidth - m_Dx, _
1)-(picGraph.ScaleWidth - 1, 101), _
picGraph.BackColor, BF
For i = 20 To 80 Step 20
picGraph.Line (picGraph.ScaleWidth - m_Dx, _
i)-(picGraph.ScaleWidth, i), vbRed
Next i
' Plot the new value.
new_value = NewValue()
picGraph.Line (picGraph.ScaleWidth - 1 - m_Dx, _
m_OldValue)-(picGraph.ScaleWidth - 1, new_value)
m_OldValue = new_value
picGraph.Picture = picGraph.Image
End Sub
|