codice:
Public Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, _
    ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
'_________________________________________________________
Sub DrawGraph(ByVal MAXNUM as Integer, ByVal VALNUM as Integer)
    Dim BarVal As Integer
    Dim BarMax As Integer
    Dim BarPercent As Single
    Dim BarRows As Integer
    Dim BarCols As Integer
    Dim BarHDC As Long
    Dim x As Long
    Dim y As Long
    BarHDC = picture1.hdc
    BarRows = picture1.ScaleHeight
    BarCols = picture1.ScaleWidth
    BarVal = VALNUM 'ES. 5
    BarMax = MAXNUM 'ES. 100
    If BarMax = 0 Then Exit Sub
    'Previene l'errore division by Zero
    If BarVal = 0 Then
        picture1.ToolTipText = "( 0.00% )"
        Exit Sub
    End If
    BarPercent = BarVal / BarMax
    'Setta la Tooltiptext sulla percentuale (ES. 15.23%)
    picpicture1.ToolTipText = "(" + Str(Int((BarPercent) * 10000) / 100) + "% )"
    For x = 0 To Round(BarCols * BarPercent)
        For y = 0 To BarRows
            SetPixel BarHDC, x, y, vbBlue'colora
        Next y
    Next x
    picture1.Refresh
End Sub