删除的内容:
'Friend WithEvents Label13 As System.Windows.Forms.Label
'Friend WithEvents Label15 As System.Windows.Forms.Label
'Friend WithEvents Label10 As System.Windows.Forms.Label
'Friend WithEvents Label4 As System.Windows.Forms.Label
'Friend WithEvents Label16 As System.Windows.Forms.Label
'Friend WithEvents Label11 As System.Windows.Forms.Label
'Friend WithEvents Label3 As System.Windows.Forms.Label
'Friend WithEvents Label2 As System.Windows.Forms.Label
'Friend WithEvents Label5 As System.Windows.Forms.Label
'Friend WithEvents Label1 As System.Windows.Forms.Label
'Friend WithEvents Label6 As System.Windows.Forms.Label
'Friend WithEvents Label12 As System.Windows.Forms.Label
'Friend WithEvents Label7 As System.Windows.Forms.Label
'Friend WithEvents Label8 As System.Windows.Forms.Label
'Friend WithEvents Label14 As System.Windows.Forms.Label
'Friend WithEvents Label9 As System.Windows.Forms.Label

'Me.Label13 = New System.Windows.Forms.Label()
'Me.Label15 = New System.Windows.Forms.Label()
'Me.Label10 = New System.Windows.Forms.Label()
'Me.Label4 = New System.Windows.Forms.Label()
'Me.Label16 = New System.Windows.Forms.Label()
'Me.Label11 = New System.Windows.Forms.Label()
'Me.Label3 = New System.Windows.Forms.Label()
'Me.Label2 = New System.Windows.Forms.Label()
'Me.Label5 = New System.Windows.Forms.Label()
'Me.Label1 = New System.Windows.Forms.Label()
'Me.Label6 = New System.Windows.Forms.Label()
'Me.Label12 = New System.Windows.Forms.Label()
'Me.Label7 = New System.Windows.Forms.Label()
'Me.Label8 = New System.Windows.Forms.Label()
'Me.Label14 = New System.Windows.Forms.Label()
'Me.Label9 = New System.Windows.Forms.Label()

'
'Label13
''
'Me.Label13.Location = New System.Drawing.Point(32, 264)
'Me.Label13.Name = "Label13"
'Me.Label13.Size = New System.Drawing.Size(32, 32)
'Me.Label13.TabIndex = 1
''
''Label15
''
'Me.Label15.Location = New System.Drawing.Point(112, 264)
'Me.Label15.Name = "Label15"
'Me.Label15.Size = New System.Drawing.Size(32, 32)
'Me.Label15.TabIndex = 1
''
''Label10
''
'Me.Label10.Location = New System.Drawing.Point(72, 224)
'Me.Label10.Name = "Label10"
'Me.Label10.Size = New System.Drawing.Size(32, 32)
'Me.Label10.TabIndex = 1
''
''Label4
''
'Me.Label4.Location = New System.Drawing.Point(152, 144)
'Me.Label4.Name = "Label4"
'Me.Label4.Size = New System.Drawing.Size(32, 32)
'Me.Label4.TabIndex = 1
''
''Label16
''
'Me.Label16.Location = New System.Drawing.Point(152, 264)
'Me.Label16.Name = "Label16"
'Me.Label16.Size = New System.Drawing.Size(32, 32)
'Me.Label16.TabIndex = 1
''
''Label11
''
'Me.Label11.Location = New System.Drawing.Point(112, 224)
'Me.Label11.Name = "Label11"
'Me.Label11.Size = New System.Drawing.Size(32, 32)
'Me.Label11.TabIndex = 1
''
''Label3
''
'Me.Label3.Location = New System.Drawing.Point(112, 144)
'Me.Label3.Name = "Label3"
'Me.Label3.Size = New System.Drawing.Size(32, 32)
'Me.Label3.TabIndex = 1
''
''Label2
''
'Me.Label2.Location = New System.Drawing.Point(72, 144)
'Me.Label2.Name = "Label2"
'Me.Label2.Size = New System.Drawing.Size(32, 32)
'Me.Label2.TabIndex = 1
''
''Label5
''
'Me.Label5.Location = New System.Drawing.Point(32, 184)
'Me.Label5.Name = "Label5"
'Me.Label5.Size = New System.Drawing.Size(32, 32)
'Me.Label5.TabIndex = 1
''
''Label1
''
'Me.Label1.Location = New System.Drawing.Point(32, 144)
'Me.Label1.Name = "Label1"
'Me.Label1.Size = New System.Drawing.Size(32, 32)
'Me.Label1.TabIndex = 1
''
''Label6
''
'Me.Label6.Location = New System.Drawing.Point(72, 184)
'Me.Label6.Name = "Label6"
'Me.Label6.Size = New System.Drawing.Size(32, 32)
'Me.Label6.TabIndex = 1
''
''Label12
''
'Me.Label12.Location = New System.Drawing.Point(152, 224)
'Me.Label12.Name = "Label12"
'Me.Label12.Size = New System.Drawing.Size(32, 32)
'Me.Label12.TabIndex = 1
''
''Label7
''
'Me.Label7.Location = New System.Drawing.Point(112, 184)
'Me.Label7.Name = "Label7"
'Me.Label7.Size = New System.Drawing.Size(32, 32)
'Me.Label7.TabIndex = 1
''
''Label8
''
'Me.Label8.Location = New System.Drawing.Point(152, 184)
'Me.Label8.Name = "Label8"
'Me.Label8.Size = New System.Drawing.Size(32, 32)
'Me.Label8.TabIndex = 1
''
''Label14
''
'Me.Label14.Location = New System.Drawing.Point(72, 264)
'Me.Label14.Name = "Label14"
'Me.Label14.Size = New System.Drawing.Size(32, 32)
'Me.Label14.TabIndex = 1
''
''Label9
''
'Me.Label9.Location = New System.Drawing.Point(32, 224)
'Me.Label9.Name = "Label9"
'Me.Label9.Size = New System.Drawing.Size(32, 32)
'Me.Label9.TabIndex = 1

'Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.TextBox5, Me.label23, Me.Label22, Me.Label18, Me.Label17, Me.Button2, Me.StartButton, Me.Label1, Me.GroupBox1, Me.Label2, Me.Label3, Me.Label4, Me.Label5, Me.Label6, Me.Label7, Me.Label8, Me.Label9, Me.Label10, Me.Label11, Me.Label12, Me.Label13, Me.Label14, Me.Label15, Me.Label16})

'label(i).Tag = Me.Count
'LabelArrayExample = New LabelArray(Me)

'For i = 1 To 15
'LabelArrayExample.AddNewLabel()
'Next

'If t.locate.X = 0 And t.locate.Y = 0 Then Label1.Text = Val(Label1.Text) + 1
'If t.locate.X = 0 And t.locate.Y = 1 Then Label2.Text = Val(Label2.Text) + 1
'If t.locate.X = 0 And t.locate.Y = 2 Then Label3.Text = Val(Label3.Text) + 1
'If t.locate.X = 0 And t.locate.Y = 3 Then Label4.Text = Val(Label4.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 0 Then Label5.Text = Val(Label5.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 1 Then Label6.Text = Val(Label6.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 2 Then Label7.Text = Val(Label7.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 3 Then Label8.Text = Val(Label8.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 0 Then Label9.Text = Val(Label9.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 1 Then Label10.Text = Val(Label10.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 2 Then Label11.Text = Val(Label11.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 3 Then Label12.Text = Val(Label12.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 0 Then Label13.Text = Val(Label13.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 1 Then Label14.Text = Val(Label14.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 2 Then Label15.Text = Val(Label15.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 3 Then Label16.Text = Val(Label16.Text) + 1

Public Class LabelArray
Inherits System.Collections.CollectionBase
Private ReadOnly HostForm As System.Windows.Forms.Form
Public Sub New(ByVal host As System.Windows.Forms.Form)
HostForm = host
Me.AddNewLabel()
End Sub

Public Sub AddNewLabel()
' 创建 Button 类的新实例。
Dim aLabel As New System.Windows.Forms.Label()
' 将按钮添加到集合的内部列表。
Me.List.Add(aLabel)
' 将按钮添加到由 HostForm 字段
' 引用的窗体的控件集合中。
HostForm.Controls.Add(aLabel)
' 设置按钮对象的初始属性。
aLabel.Location = New System.Drawing.Point(32 + ((Count - 1) Mod 4) * 40, 144 + ((Count - 1) \ 4) * 40)
aLabel.Name = "Label" & Str(Count)
aLabel.Size = New System.Drawing.Size(32, 32)
aLabel.Tag = Me.Count
aLabel.Text = ""
End Sub
End Class




新增的部分内容:
Friend label(16) As System.Windows.Forms.Label

'
'Label()
'
For i = 0 To 15
label(i) = New System.Windows.Forms.Label()
label(i).Location = New System.Drawing.Point(32 + ((i) Mod 4) * 40, 144 + ((i) \ 4) * 40)
label(i).Name = "Label" & Str(i + 1)
label(i).Size = New System.Drawing.Size(32, 32)
label(i).Text = ""
Me.Controls.Add(Me.label(i))

Next

Private Sub printbact(ByVal t As bacteria)
label(t.locate.X * 4 + t.locate.Y).Text = Val(label(t.locate.X * 4 + t.locate.Y).Text) + 1
End Sub
'Friend WithEvents Label13 As System.Windows.Forms.Label
'Friend WithEvents Label15 As System.Windows.Forms.Label
'Friend WithEvents Label10 As System.Windows.Forms.Label
'Friend WithEvents Label4 As System.Windows.Forms.Label
'Friend WithEvents Label16 As System.Windows.Forms.Label
'Friend WithEvents Label11 As System.Windows.Forms.Label
'Friend WithEvents Label3 As System.Windows.Forms.Label
'Friend WithEvents Label2 As System.Windows.Forms.Label
'Friend WithEvents Label5 As System.Windows.Forms.Label
'Friend WithEvents Label1 As System.Windows.Forms.Label
'Friend WithEvents Label6 As System.Windows.Forms.Label
'Friend WithEvents Label12 As System.Windows.Forms.Label
'Friend WithEvents Label7 As System.Windows.Forms.Label
'Friend WithEvents Label8 As System.Windows.Forms.Label
'Friend WithEvents Label14 As System.Windows.Forms.Label
'Friend WithEvents Label9 As System.Windows.Forms.Label
'Me.Label13 = New System.Windows.Forms.Label()
'Me.Label15 = New System.Windows.Forms.Label()
'Me.Label10 = New System.Windows.Forms.Label()
'Me.Label4 = New System.Windows.Forms.Label()
'Me.Label16 = New System.Windows.Forms.Label()
'Me.Label11 = New System.Windows.Forms.Label()
'Me.Label3 = New System.Windows.Forms.Label()
'Me.Label2 = New System.Windows.Forms.Label()
'Me.Label5 = New System.Windows.Forms.Label()
'Me.Label1 = New System.Windows.Forms.Label()
'Me.Label6 = New System.Windows.Forms.Label()
'Me.Label12 = New System.Windows.Forms.Label()
'Me.Label7 = New System.Windows.Forms.Label()
'Me.Label8 = New System.Windows.Forms.Label()
'Me.Label14 = New System.Windows.Forms.Label()
'Me.Label9 = New System.Windows.Forms.Label()
'
'Label13
''
'Me.Label13.Location = New System.Drawing.Point(32, 264)
'Me.Label13.Name = "Label13"
'Me.Label13.Size = New System.Drawing.Size(32, 32)
'Me.Label13.TabIndex = 1
''
''Label15
''
'Me.Label15.Location = New System.Drawing.Point(112, 264)
'Me.Label15.Name = "Label15"
'Me.Label15.Size = New System.Drawing.Size(32, 32)
'Me.Label15.TabIndex = 1
''
''Label10
''
'Me.Label10.Location = New System.Drawing.Point(72, 224)
'Me.Label10.Name = "Label10"
'Me.Label10.Size = New System.Drawing.Size(32, 32)
'Me.Label10.TabIndex = 1
''
''Label4
''
'Me.Label4.Location = New System.Drawing.Point(152, 144)
'Me.Label4.Name = "Label4"
'Me.Label4.Size = New System.Drawing.Size(32, 32)
'Me.Label4.TabIndex = 1
''
''Label16
''
'Me.Label16.Location = New System.Drawing.Point(152, 264)
'Me.Label16.Name = "Label16"
'Me.Label16.Size = New System.Drawing.Size(32, 32)
'Me.Label16.TabIndex = 1
''
''Label11
''
'Me.Label11.Location = New System.Drawing.Point(112, 224)
'Me.Label11.Name = "Label11"
'Me.Label11.Size = New System.Drawing.Size(32, 32)
'Me.Label11.TabIndex = 1
''
''Label3
''
'Me.Label3.Location = New System.Drawing.Point(112, 144)
'Me.Label3.Name = "Label3"
'Me.Label3.Size = New System.Drawing.Size(32, 32)
'Me.Label3.TabIndex = 1
''
''Label2
''
'Me.Label2.Location = New System.Drawing.Point(72, 144)
'Me.Label2.Name = "Label2"
'Me.Label2.Size = New System.Drawing.Size(32, 32)
'Me.Label2.TabIndex = 1
''
''Label5
''
'Me.Label5.Location = New System.Drawing.Point(32, 184)
'Me.Label5.Name = "Label5"
'Me.Label5.Size = New System.Drawing.Size(32, 32)
'Me.Label5.TabIndex = 1
''
''Label1
''
'Me.Label1.Location = New System.Drawing.Point(32, 144)
'Me.Label1.Name = "Label1"
'Me.Label1.Size = New System.Drawing.Size(32, 32)
'Me.Label1.TabIndex = 1
''
''Label6
''
'Me.Label6.Location = New System.Drawing.Point(72, 184)
'Me.Label6.Name = "Label6"
'Me.Label6.Size = New System.Drawing.Size(32, 32)
'Me.Label6.TabIndex = 1
''
''Label12
''
'Me.Label12.Location = New System.Drawing.Point(152, 224)
'Me.Label12.Name = "Label12"
'Me.Label12.Size = New System.Drawing.Size(32, 32)
'Me.Label12.TabIndex = 1
''
''Label7
''
'Me.Label7.Location = New System.Drawing.Point(112, 184)
'Me.Label7.Name = "Label7"
'Me.Label7.Size = New System.Drawing.Size(32, 32)
'Me.Label7.TabIndex = 1
''
''Label8
''
'Me.Label8.Location = New System.Drawing.Point(152, 184)
'Me.Label8.Name = "Label8"
'Me.Label8.Size = New System.Drawing.Size(32, 32)
'Me.Label8.TabIndex = 1
''
''Label14
''
'Me.Label14.Location = New System.Drawing.Point(72, 264)
'Me.Label14.Name = "Label14"
'Me.Label14.Size = New System.Drawing.Size(32, 32)
'Me.Label14.TabIndex = 1
''
''Label9
''
'Me.Label9.Location = New System.Drawing.Point(32, 224)
'Me.Label9.Name = "Label9"
'Me.Label9.Size = New System.Drawing.Size(32, 32)
'Me.Label9.TabIndex = 1
'Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.TextBox5, Me.label23, Me.Label22, Me.Label18, Me.Label17, Me.Button2, Me.StartButton, Me.Label1, Me.GroupBox1, Me.Label2, Me.Label3, Me.Label4, Me.Label5, Me.Label6, Me.Label7, Me.Label8, Me.Label9, Me.Label10, Me.Label11, Me.Label12, Me.Label13, Me.Label14, Me.Label15, Me.Label16})
'label(i).Tag = Me.Count
'LabelArrayExample = New LabelArray(Me)
'For i = 1 To 15
'LabelArrayExample.AddNewLabel()
'Next
'If t.locate.X = 0 And t.locate.Y = 0 Then Label1.Text = Val(Label1.Text) + 1
'If t.locate.X = 0 And t.locate.Y = 1 Then Label2.Text = Val(Label2.Text) + 1
'If t.locate.X = 0 And t.locate.Y = 2 Then Label3.Text = Val(Label3.Text) + 1
'If t.locate.X = 0 And t.locate.Y = 3 Then Label4.Text = Val(Label4.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 0 Then Label5.Text = Val(Label5.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 1 Then Label6.Text = Val(Label6.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 2 Then Label7.Text = Val(Label7.Text) + 1
'If t.locate.X = 1 And t.locate.Y = 3 Then Label8.Text = Val(Label8.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 0 Then Label9.Text = Val(Label9.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 1 Then Label10.Text = Val(Label10.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 2 Then Label11.Text = Val(Label11.Text) + 1
'If t.locate.X = 2 And t.locate.Y = 3 Then Label12.Text = Val(Label12.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 0 Then Label13.Text = Val(Label13.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 1 Then Label14.Text = Val(Label14.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 2 Then Label15.Text = Val(Label15.Text) + 1
'If t.locate.X = 3 And t.locate.Y = 3 Then Label16.Text = Val(Label16.Text) + 1
Public Class LabelArray
Inherits System.Collections.CollectionBase
Private ReadOnly HostForm As System.Windows.Forms.Form
Public Sub New(ByVal host As System.Windows.Forms.Form)
HostForm = host
Me.AddNewLabel()
End Sub
Public Sub AddNewLabel()
' 创建 Button 类的新实例。
Dim aLabel As New System.Windows.Forms.Label()
' 将按钮添加到集合的内部列表。
Me.List.Add(aLabel)
' 将按钮添加到由 HostForm 字段
' 引用的窗体的控件集合中。
HostForm.Controls.Add(aLabel)
' 设置按钮对象的初始属性。
aLabel.Location = New System.Drawing.Point(32 + ((Count - 1) Mod 4) * 40, 144 + ((Count - 1) \ 4) * 40)
aLabel.Name = "Label" & Str(Count)
aLabel.Size = New System.Drawing.Size(32, 32)
aLabel.Tag = Me.Count
aLabel.Text = ""
End Sub
End Class



新增的部分内容:
Friend label(16) As System.Windows.Forms.Label
'
'Label()
'
For i = 0 To 15
label(i) = New System.Windows.Forms.Label()
label(i).Location = New System.Drawing.Point(32 + ((i) Mod 4) * 40, 144 + ((i) \ 4) * 40)
label(i).Name = "Label" & Str(i + 1)
label(i).Size = New System.Drawing.Size(32, 32)
label(i).Text = ""
Me.Controls.Add(Me.label(i))
Next
Private Sub printbact(ByVal t As bacteria)
label(t.locate.X * 4 + t.locate.Y).Text = Val(label(t.locate.X * 4 + t.locate.Y).Text) + 1
End Sub

浙公网安备 33010602011771号