Spidermans_DarkSide - VSIP
Hi ALL,
I tried this>>
I've tried the following and it works without an exception thrown.
Any ideas why a Timer as Timer1 does not throw an exception
Regards,
S_DS
____________________________________________
'Add an imports statement.
'The previous project name becomes the NAMESPACE.
'The CLASS name is after the dot.
Imports
Star_On_A_Wotsit.Star
Public
Class Form1
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim myPen As New Pen(Color.Turquoise)
'Draw a star with myPen, pen Width is 10 pixels,
' at 100,100
' size of 50 pixels with 10 radial arms.
newStar(PictureBox1, myPen, 10, 100, 100, 50, 10)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Text = Now.ToLongDateString & " " & Now.ToLongTimeString
End Sub
End
Class
with the TIMER an exception is not thrown, any ideas why
In other words try this into the code above instead>>
newStar(Timer1, myPen, 10, 100, 100, 50, 10)
My DLL project name is called Star_On_A_Wotsit hence the namespace name in the IMPORTS statement above.
Here is the STAR CLASS code if you want to play with it >>
Public
Class Star
'Pass an object such as a PICTUREBOX with a PEN of a WIDTH
'with myX1,myY1 as the star centre and a SIZE in pixels
'with however many radial arms you want as numOfArms.
Public Shared Sub newStar _
(
ByVal obj As Object, _
ByVal somePen As Pen, _
ByVal width As Integer, _
ByVal myX1 As Integer, _
ByVal myY1 As Integer, _
ByVal Size As Integer, _
ByVal numOfArms As Integer)
'Set the Pen width.
With somePen
.Width = width
End With
'X1,Y1 hold the calculated points.
Dim x1 As Integer
Dim y1 As Integer
'Count is used in a FOR NEXT loop.
Dim count As Double
'Create a variable to hold 2 times Pi
Dim twoPi As Double = 2 * Math.PI
'Now draw the STAR!!
For count = 0 To twoPi Step twoPi / numOfArms
x1 = Size * Math.Sin(count) + myX1
y1 = Size * Math.Cos(count) + myY1
obj.CreateGraphics.DrawLine(somePen, x1, y1, myX1, myY1)
Next
End Sub
End
Class