I am trying to use the following code in a button. I want to call DrawLineFloat. I tried call DrawLineFloat() but it did not work. What do I need to enter in ()?
Thanks
Public Sub DrawLineFloat(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create coordinates of points that define line.
Dim x1 As Single = 100.0F
Dim y1 As Single = 100.0F
Dim x2 As Single = 500.0F
Dim y2 As Single = 100.0F
' Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)
End Sub
I suppose you are calling this inside a form, but not in the Paint event.
So you need to create the Graphics used to draw your line
Also note that the Pen object should be disposed as soon as possible