Public Class Form1
    Dim s As Integer
    Dim g As Graphics
    Private PerCounter As System.Diagnostics.PerformanceCounter
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        s = s + 1
        Label2.Text = Str(s)
        Dim c As Integer
        c = Label2.Text
        Dim i As Integer = Integer.Parse(Format(PerCounter.NextValue, "##0"))
        Label1.Text = "CPU: " & i & " %"
        g = PictureBox1.CreateGraphics
        g.DrawLine(Pens.Yellow, c, 100, c, i)
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PerCounter = New System.Diagnostics.PerformanceCounter
        PerCounter.CategoryName = "Processor"
        PerCounter.CounterName = "% Processor Time"
        PerCounter.InstanceName = "_Total"
        s = s + 1
        Label2.Text = Str(s)
        Dim c As Integer
        c = Label2.Text
        Dim i As Integer = Integer.Parse(Format(PerCounter.NextValue, "##0"))
        Label1.Text = "CPU: " & i & " %"
        g = PictureBox1.CreateGraphics
        g.DrawLine(Pens.Yellow, c, i, c, i)
    End Sub
End Class
