By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,855 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,855 IT Pros & Developers. It's quick & easy.

Draw line VB2005

P: n/a

I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to call the
sub. I want my code to determine the two points then have the sub draw the
line.

Call DrawLinePoint() don't work and I don't know what value to pass it. I
hope I am just missing something simple here.
Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
<th*****@msala.net> schrieb:
I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to call the
sub. I want my code to determine the two points then have the sub draw
the
line.

Call DrawLinePoint() don't work and I don't know what value to pass it. I
hope I am just missing something simple here.


Place the code in the form's or control's 'Paint' event handler or override
its 'OnPaint' method and perform the drawing there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
<th*****@msala.net> schrieb

I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to
call the sub. I want my code to determine the two points then have
the sub draw the line.

Call DrawLinePoint() don't work and I don't know what value to pass
it. I hope I am just missing something simple here.

'PaintEventArgs' are passed to the Paint event. Handle the event of the
object you want to draw on and pass the argument called 'e' to the sub.
Armin

Nov 21 '05 #3

P: n/a
DrawLinePoint has to handle the form/control's paint event. Otherwise,
it won't display.

th*****@msala.net wrote:
I found the following code on MSDN to draw a line in VB2005.

Public Sub DrawLinePoint(ByVal e As PaintEventArgs)

' Create pen.
Dim blackPen As New Pen(Color.Black, 3)

' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)

' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)

End Sub

This seems to be just what I need, but I can't figure out how to call the
sub. I want my code to determine the two points then have the sub draw the
line.

Call DrawLinePoint() don't work and I don't know what value to pass it. I
hope I am just missing something simple here.
Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Nov 21 '05 #4

P: n/a

I have got it working. I just have to write some code that will only paint
it when I want it. I don't want the line painted everytime the form is
loaded or refreshed.

Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.