3
Answers

Class and Picturebox

mmulibra

mmulibra

19y
7k
1
Hi, I know I am abit slow, sorry, but I am facing a problem with this code. I need to a have mouseclick to event to draw a circle in a picturebox. All the circles will have different properties at the later stage, that is the reason I am using class. There are some problems : For my mouse event : VB.NET Code: Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp Dim myCity As New city Dim i, j As Integer Dim Xpos, YPos As Single Xpos = e.X YPos = e.Y If e.Button = MouseButtons.Left Then i = i + 1 myCity.NewCity(Xpos, YPos, "Node" + i) myCity.DrawCity(PictureBox1) End If The problem with the mouse event is, I cant seem to able to type " Dim myCity As New City() " it always end up as "Dim myCity as New city" with the error of type city expected (error BC30182: Type expected.) For City class : VB.NET Code: Public Class City Dim mXPos, mYPos As Single Dim mName As String Public Sub NewCity(ByVal X As Single, ByVal Y As Single, ByVal CityName As String) mXPos = X mYPos = Y mName = CityName End Sub Public Function DrawCity(ByVal PictureBox1 As PictureBox) PictureBox1.Circle(mXPos, mYPos) End Function End Class As for my City class, I have this error : error BC30002: Type 'PictureBox' is not defined. Thanks.
Answers (3)