Conway的生活游戏中的图形" MissingMemberException"在Visual Studio 2015中

时间:2016-12-21 00:52:41

标签: vb.net winforms visual-studio-2015

Public Class GameOfLife
Dim grid(63, 63) As Boolean
Dim input(63, 63) As Boolean
Dim generations As Integer = 0
Dim change As Boolean = False

Sub GameOfLife_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    For i As Integer = 0 To 63
        For j As Integer = 0 To 63
            grid(i, j) = False
        Next
    Next

    Dim g As Graphics = sender.Graphics
    g.Clear(Color.White)
    g.PageUnit = GraphicsUnit.Pixel
    Dim rect As Rectangle
    For i As Integer = 10 To 640 Step 10
        g.DrawLine(Pens.Black, 0, i, 640, i)
        g.DrawLine(Pens.Black, i, 0, i, 640)
    Next
    For i As Integer = 0 To 63
        For j As Integer = 0 To 63
            If grid(i, j) Then
                rect = New Rectangle(i * 10, j * 10, 10, 10)
                g.FillRectangle(Brushes.Black, rect)
            End If
        Next
    Next
End Sub

当我尝试在Visual Studio中构建它时,它会抛出" MissingMemberException"在尝试构建Dim g as Graphics = sender.Graphics时 - Visual Studio 2015认为Graphics是一个类,但它不是。如何绕过例外?

注意:这不是代码中唯一的Sub,但如果需要,我会提供完整的代码。

0 个答案:

没有答案