Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Sub Drawline(Routeindex As Integer, cityindex As Integer)
 NumRoutes = NumRoutes + 1

Load Route(Routeindex)
With Route(Routeindex)
        .X1 = DB(cityindex) + NumRoutes
        .Y1 = DB(cityindex)  + NumRoutes
        .X2 = DB - NumRoutes
        .Y2 = DB - NumRoutes
        .Visible = True

End With


End Sub
Posted
Comments
Ron Beyer 22-Jun-13 0:14am    
Please clarify your question. What are you drawing on? What platform are you using (WinForms, WPF, ASP, WebForms, etc). What are the X and Y values (pixels, miles, kilometers)?

1 solution

If you are using vb.net and you want to draw line in picturebox control using mouse then

VB
Dim startpoint As Point
   Dim endpoint As Point
   Dim flag As Boolean = False
   Private Sub PictureBox1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
       startpoint = New Point(e.X, e.Y)
       flag = True

   End Sub


   Private Sub PictureBox1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
       If flag Then
           Dim g As Graphics = PictureBox1.CreateGraphics()
           endpoint = New Point(e.X, e.Y)
           g.Clear(Color.White)
           g.DrawLine(Pens.Black, startpoint, endpoint)
       End If
   End Sub

   Private Sub PictureBox1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
       flag = False
   End Sub



If you want to draw line on form window then use
VB
me
instead of
VB
picturebox1
and use form events instead of picturebox mouse events.
 
Share this answer
 
v2
Comments
Chand Sitare 16-Jul-13 9:02am    
It's really usefull for me. But can you tell me what how to draw circle and rectangle. Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900