Drawing/Plotting in VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alain44
    New Member
    • Oct 2007
    • 1

    Drawing/Plotting in VB.NET

    Hi
    Can someone help me plotting results on a picturebox using VB.NET ?
    Based on VB’s help I made up the following code – which works fine as long as the Do-While-loop is disconnected by the ‘Exit Sub’ in line 6 of sub Button1_Click – but if the loop is active as needed for plotting there happens no drawing at all.
    What’s wrong ???
    [code=vbnet]
    Public Class AnalResult
    Dim RcDraw As Rectangle
    Dim PenWidth As Integer = 4
    Dim Warten As Boolean
    Dim Pen1 As New Pen(Color.Blue, PenWidth)
    'Dim e1 As New System.Windows. Forms.PaintEven tArgs
    Public PosTrade%, NegTrade%, PosTradeT#, NegTradeT#, PosTop#, NegBottom#, BiggestLoss#, LongestDown%, Massst#, NullN#


    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
    Static i% = 0
    Do While i < 2000
    i = i + 4
    Z(i)
    'Exit Sub ‘ <<<<<<<<< if no exit – no drawing at all
    Loop
    End Sub

    Public Sub Z(ByVal Yw%)
    If RcDraw.X = 0 Then RcDraw.X = 20
    Dim i%
    i = PictureBox1.Hei ght - (G_ResT * Massst + NullN)
    If Yw = 0 Then Yw = i
    RcDraw.X = RcDraw.X + 4
    If PictureBox1.Wid th < RcDraw.X + 8 Then
    Exit Sub
    PictureBox1.Wid th = RcDraw.X + 8
    Me.Width = PictureBox1.Wid th + (1137 - 744)
    End If
    RcDraw.Width = 4 ' RcDraw.X - e.X
    RcDraw.Height = 4 ' RcDraw.Y - e.Y
    RcDraw.Y = Yw ' 81 ' e.Y
    PictureBox1.Inv alidate(RcDraw)
    End Sub

    Private Sub PictureBox1_Pai nt(ByVal sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles PictureBox1.Pai nt
    e.Graphics.Draw Rectangle(Pens. Blue, RcDraw)
    'e.Graphics.Dra wRectangle(New Pen(Color.Blue, PenWidth), RcDraw)
    End Sub
    End Class
    [/code]
    Many thanks for help !!
    Alain
    Last edited by debasisdas; Nov 3 '07, 10:12 AM. Reason: Formatted using code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET Forum.

    Comment

    Working...