Hej
Jag får inte igång min metod, ShowInfo.
koden jag har:
Public Class Form1
Private mybox As Box
Private info As arvBox
Private graphArea As Graphics
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mybox.MoveUpp(20)
graphArea.Clear(gPic.BackColor)
mybox.ShowBox(graphArea)
End Sub
End Class
Public Class Box
Public x As Integer = 10 'Private
Public y As Integer = 50
Public widthR As Integer = 15
Public heightR As Integer = 15
Dim myPen As Pen = New Pen(Color.Red, 2)
Public Sub ShowBox(ByVal graphArea As Graphics)
graphArea.DrawRectangle(myPen, x, y, widthR, heightR)
End Sub
Public Sub MoveUpp(ByVal dy As Integer)
y -= dy
End Sub
End Class
Det är denna jag vill starta, men det vill sig inte :(
Public Class arvBox
Inherits Box
Public Sub ShowInfo(ByVal graphArea As Graphics)
Dim sb As SolidBrush = New SolidBrush(Color.Red)
Dim st As String = x & " " & y
Dim f As Font = New Font("Arial", 12, FontStyle.Bold)
graphArea.DrawString(st, f, sb, x, y)
End Sub
End Class
Har provat med
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mybox.MoveUpp(20)
graphArea.Clear(gPic.BackColor)
mybox.ShowBox(graphArea)
info.ShowInfo(graphArea)
End Sub
Men får då felmeddelandet:
Objektreferensen har inte angetts till en instans av ett objekt.
Hur löser jag detta??
Tacksam för all hjälp :stud