050612BacteriumAntiMedicine v0.1

Posted on 2005-06-12 18:33  岳洋  阅读(420)  评论(0)    收藏  举报

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region "变量声明"
    Public Structure medicine
        Public area As Byte
        Public killrate As Byte
    End Structure
    Public Structure bacteria
        Public locate As System.Drawing.Point
        Public antimedicine() As Boolean
        Public alive As Boolean
    End Structure
    Public CurrentMedicine As Byte
    Public med(10) As medicine
    Public bact(50) As bacteria
    Public i, j, sum As Short
    Public t As bacteria
    Public boi, boj As Boolean
    Public lastbact As Byte
    Public BacteriumAntiMedicineRate As Byte = 50
    Dim ro As System.Random = New Random
#End Region

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend Label(10, 10) As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents Label14 As System.Windows.Forms.Label
    Friend WithEvents Label15 As System.Windows.Forms.Label
    Friend WithEvents Label16 As System.Windows.Forms.Label
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Label17 As System.Windows.Forms.Label
    Friend WithEvents Label18 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Label19 As System.Windows.Forms.Label
    Friend WithEvents Label20 As System.Windows.Forms.Label
    Friend WithEvents Label21 As System.Windows.Forms.Label
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    Friend WithEvents Label22 As System.Windows.Forms.Label
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Button5 As System.Windows.Forms.Button
    Friend WithEvents StartButton As System.Windows.Forms.Button
    Friend WithEvents label23 As System.Windows.Forms.Label
    Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Button5 = New System.Windows.Forms.Button
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.Label21 = New System.Windows.Forms.Label
        Me.Label20 = New System.Windows.Forms.Label
        Me.Label19 = New System.Windows.Forms.Label
        Me.Button3 = New System.Windows.Forms.Button
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox3 = New System.Windows.Forms.TextBox
        Me.TextBox4 = New System.Windows.Forms.TextBox
        Me.Button4 = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label9 = New System.Windows.Forms.Label
        Me.Label10 = New System.Windows.Forms.Label
        Me.Label11 = New System.Windows.Forms.Label
        Me.Label12 = New System.Windows.Forms.Label
        Me.Label13 = New System.Windows.Forms.Label
        Me.Label14 = New System.Windows.Forms.Label
        Me.Label15 = New System.Windows.Forms.Label
        Me.Label16 = New System.Windows.Forms.Label
        Me.StartButton = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Label17 = New System.Windows.Forms.Label
        Me.Label18 = New System.Windows.Forms.Label
        Me.Label22 = New System.Windows.Forms.Label
        Me.label23 = New System.Windows.Forms.Label
        Me.TextBox5 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Timer1
        '
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Button5)
        Me.GroupBox1.Controls.Add(Me.TextBox2)
        Me.GroupBox1.Controls.Add(Me.Label21)
        Me.GroupBox1.Controls.Add(Me.Label20)
        Me.GroupBox1.Controls.Add(Me.Label19)
        Me.GroupBox1.Controls.Add(Me.Button3)
        Me.GroupBox1.Controls.Add(Me.TextBox1)
        Me.GroupBox1.Controls.Add(Me.TextBox3)
        Me.GroupBox1.Controls.Add(Me.TextBox4)
        Me.GroupBox1.Controls.Add(Me.Button4)
        Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(456, 120)
        Me.GroupBox1.TabIndex = 0
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "抗生素"
        '
        'Button5
        '
        Me.Button5.Location = New System.Drawing.Point(344, 24)
        Me.Button5.Name = "Button5"
        Me.Button5.TabIndex = 8
        Me.Button5.Text = "Accept"
        '
        'TextBox2
        '
        Me.TextBox2.Enabled = False
        Me.TextBox2.Location = New System.Drawing.Point(168, 24)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(56, 21)
        Me.TextBox2.TabIndex = 5
        Me.TextBox2.Text = ""
        '
        'Label21
        '
        Me.Label21.Location = New System.Drawing.Point(8, 56)
        Me.Label21.Name = "Label21"
        Me.Label21.Size = New System.Drawing.Size(96, 24)
        Me.Label21.TabIndex = 4
        Me.Label21.Text = "anti-it-number"
        '
        'Label20
        '
        Me.Label20.Location = New System.Drawing.Point(224, 24)
        Me.Label20.Name = "Label20"
        Me.Label20.Size = New System.Drawing.Size(56, 24)
        Me.Label20.TabIndex = 3
        Me.Label20.Text = "killrate"
        '
        'Label19
        '
        Me.Label19.Location = New System.Drawing.Point(128, 24)
        Me.Label19.Name = "Label19"
        Me.Label19.Size = New System.Drawing.Size(40, 24)
        Me.Label19.TabIndex = 2
        Me.Label19.Text = "area"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(48, 24)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(64, 24)
        Me.Button3.TabIndex = 1
        Me.Button3.Text = "Refresh"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(8, 24)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(32, 21)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = ""
        '
        'TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(280, 24)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(56, 21)
        Me.TextBox3.TabIndex = 5
        Me.TextBox3.Text = ""
        '
        'TextBox4
        '
        Me.TextBox4.Location = New System.Drawing.Point(104, 56)
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(56, 21)
        Me.TextBox4.TabIndex = 5
        Me.TextBox4.Text = ""
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(168, 56)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(80, 24)
        Me.Button4.TabIndex = 7
        Me.Button4.Text = "Drop Med."
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        '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
        '
        'StartButton
        '
        Me.StartButton.Location = New System.Drawing.Point(384, 136)
        Me.StartButton.Name = "StartButton"
        Me.StartButton.Size = New System.Drawing.Size(80, 24)
        Me.StartButton.TabIndex = 2
        Me.StartButton.Text = "Start"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(384, 168)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(80, 24)
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "Drop Bact."
        '
        'Label17
        '
        Me.Label17.Location = New System.Drawing.Point(192, 144)
        Me.Label17.Name = "Label17"
        Me.Label17.Size = New System.Drawing.Size(64, 24)
        Me.Label17.TabIndex = 4
        Me.Label17.Text = "lastbact"
        '
        'Label18
        '
        Me.Label18.Location = New System.Drawing.Point(264, 144)
        Me.Label18.Name = "Label18"
        Me.Label18.Size = New System.Drawing.Size(32, 32)
        Me.Label18.TabIndex = 5
        '
        'Label22
        '
        Me.Label22.Location = New System.Drawing.Point(312, 136)
        Me.Label22.Name = "Label22"
        Me.Label22.Size = New System.Drawing.Size(40, 24)
        Me.Label22.TabIndex = 6
        Me.Label22.Text = "Off"
        '
        'label23
        '
        Me.label23.Location = New System.Drawing.Point(192, 184)
        Me.label23.Name = "label23"
        Me.label23.Size = New System.Drawing.Size(64, 32)
        Me.label23.TabIndex = 7
        Me.label23.Text = "Bact.Anti-Med.rate"
        '
        'TextBox5
        '
        Me.TextBox5.Location = New System.Drawing.Point(256, 184)
        Me.TextBox5.Name = "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(40, 21)
        Me.TextBox5.TabIndex = 8
        Me.TextBox5.Text = "50"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(304, 184)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(56, 24)
        Me.Button1.TabIndex = 9
        Me.Button1.Text = "Accept"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(480, 334)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox5)
        Me.Controls.Add(Me.label23)
        Me.Controls.Add(Me.Label22)
        Me.Controls.Add(Me.Label18)
        Me.Controls.Add(Me.Label17)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.StartButton)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.Label10)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.Label12)
        Me.Controls.Add(Me.Label13)
        Me.Controls.Add(Me.Label14)
        Me.Controls.Add(Me.Label15)
        Me.Controls.Add(Me.Label16)
        Me.Name = "Form1"
        Me.Text = "细菌抗药性模拟器"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 0 To 9
            med(i).area = 15
            med(i).killrate = 70
        Next
        For i = 0 To 49
            ReDim bact(i).antimedicine(10)
            For Each boi In bact(i).antimedicine
                boi = False
            Next
        Next
        CurrentMedicine = 0
        firstready()
    End Sub
    Private Sub firstready()
        clearlabel()
        lastbact = 0

    End Sub
    Private Sub newbact(ByVal number As Byte)
        Dim ro As System.Random = New Random
        bact(number).locate.X = (ro.Next(0, 4))
        bact(number).locate.Y = (ro.Next(0, 4))
        bact(number).alive = True
        For i = 0 To 9
            bact(number).antimedicine(i) = False
        Next
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
        Timer1.Interval = 20
        Timer1.Enabled = True
        Timer1.Start()
        StartButton.Enabled = False
        Label22.Text = "On"
    End Sub
    Private Sub printbact(ByVal t As bacteria)
        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
    End Sub
    Private Sub clearlabel()
        Label1.Text = "0"
        Label2.Text = "0"
        Label3.Text = "0"
        Label4.Text = "0"
        Label5.Text = "0"
        Label6.Text = "0"
        Label7.Text = "0"
        Label8.Text = "0"
        Label9.Text = "0"
        Label10.Text = "0"
        Label11.Text = "0"
        Label12.Text = "0"
        Label13.Text = "0"
        Label14.Text = "0"
        Label15.Text = "0"
        Label16.Text = "0"
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        clearlabel()
        Label18.Text = Str(lastbact)
        sum = 0
        For Each t In bact
            If t.alive = True Then
                printbact(t)
                boi = True
                For Each boj In t.antimedicine
                    If boj = False Then
                        boi = False
                        Exit For
                    End If
                    If boi = True Then
                        Timer1.Stop()
                        Label22.Text = "Off"
                        StartButton.Enabled = "True"
                        If MsgBox("Super bacteria appeared!Go on?", MsgBoxStyle.YesNo, "Super bacteria appeared!") = MsgBoxResult.Yes Then
                            Timer1.Start()
                            Label22.Text = "On"
                            StartButton.Enabled = False
                        End If

                        Exit Sub
                    End If
                Next
                sum = sum + 1
            End If
        Next
        If sum = 0 And lastbact <> 0 Then
            Timer1.Stop()
            Label22.Text = "Off"
            StartButton.Enabled = True
            MsgBox("All the bacterium died!")
            Exit Sub
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If lastbact = 50 Then
            MsgBox("maxium number of bacts!")
        Else
            lastbact = lastbact + 1
            newbact(lastbact - 1)
            refleshmap()
        End If
    End Sub
    Private Sub refleshmap()
        clearlabel()
        Label18.Text = Str(lastbact)
        For Each t In bact
            If t.alive = True Then
                printbact(t)
            End If
        Next
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If Not (IsNumeric(TextBox1.Text)) Then
            MsgBox("Must be number!")
        Else
            If Int(Val(TextBox1.Text)) <> Val(TextBox1.Text) Then
                MsgBox("Must be integer!")
            Else
                If Val(TextBox1.Text) > 10 Or Val(TextBox1.Text) < 0 Then
                    MsgBox("Must be more than -1 and less than 11!")
                Else
                    CurrentMedicine = Val(TextBox1.Text)
                    printinfo(CurrentMedicine)
                End If
            End If
        End If
    End Sub
    Private Sub printinfo(ByVal i As Short)
        TextBox2.Text = med(CurrentMedicine).area
        TextBox3.Text = med(CurrentMedicine).killrate
        sum = 0
        For j = 0 To 49
            If bact(j).alive And bact(j).antimedicine(i) = True Then sum += 1
        Next
        TextBox4.Text = sum
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If Not (IsNumeric(TextBox2.Text)) Then
            MsgBox("Must be number!")
        Else
            If Int(Val(TextBox2.Text)) <> Val(TextBox2.Text) Then
                MsgBox("Must be integer!")
            Else
                If Val(TextBox2.Text) > 100 Or Val(TextBox2.Text) < 0 Then
                    MsgBox("Must be no more than 100 and no less than 0!")
                Else
                    med(CurrentMedicine).area = Val(TextBox2.Text)
                End If
            End If
        End If
        If Not (IsNumeric(TextBox3.Text)) Then
            MsgBox("Must be number!")
        Else
            If Int(Val(TextBox3.Text)) <> Val(TextBox3.Text) Then
                MsgBox("Must be integer!")
            Else
                If Val(TextBox3.Text) > 100 Or Val(TextBox3.Text) < 0 Then
                    MsgBox("Must be no more than 100 and no less than 0!")
                Else
                    med(CurrentMedicine).killrate = Val(TextBox3.Text)
                End If
            End If
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        For i = 0 To 49
            If bact(i).alive Then
                If Not (bact(i).antimedicine(CurrentMedicine)) Then
                    If rate(med(CurrentMedicine).killrate) Then
                        bact(i).alive = False
                    Else
                        If rate(BacteriumAntiMedicineRate) Then
                            bact(i).antimedicine(CurrentMedicine) = True
                        End If
                    End If
                End If
            End If
        Next
        refleshmap()
    End Sub
    Private Function rate(ByVal j As Byte) As Boolean
        If ro.Next(1, 100) <= j Then
            Return True
        Else
            Return False
        End If
    End Function

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not (IsNumeric(TextBox5.Text)) Then
            MsgBox("Must be number!")
        Else
            If Int(Val(TextBox5.Text)) <> Val(TextBox5.Text) Then
                MsgBox("Must be integer!")
            Else
                If Val(TextBox5.Text) > 100 Or Val(TextBox5.Text) < 0 Then
                    MsgBox("Must be no more than 100 and no less than 0!")
                Else
                    BacteriumAntiMedicineRate = Val(TextBox5.Text)
                End If
            End If
        End If
    End Sub
End Class

 

Public Class Form1
    
Inherits System.Windows.Forms.Form
#Region "变量声明"
    
Public Structure medicine
        
Public area As Byte
        
Public killrate As Byte
    
End Structure

    
Public Structure bacteria
        
Public locate As System.Drawing.Point
        
Public antimedicine() As Boolean
        
Public alive As Boolean
    
End Structure

    
Public CurrentMedicine As Byte
    
Public med(10As medicine
    
Public bact(50As bacteria
    
Public i, j, sum As Short
    
Public t As bacteria
    
Public boi, boj As Boolean
    
Public lastbact As Byte
    
Public BacteriumAntiMedicineRate As Byte = 50
    
Dim ro As System.Random = New Random
#End Region


#Region " Windows 窗体设计器生成的代码 "

    
Public Sub New()
        
MyBase.New()

        
'该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        
'在 InitializeComponent() 调用之后添加任何初始化

    
End Sub


    
'窗体重写处置以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        
If disposing Then
            
If Not (components Is NothingThen
                components.Dispose()
            
End If
        
End If
        
MyBase.Dispose(disposing)
    
End Sub


    
'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    
'注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    
Friend Label(1010As System.Windows.Forms.Label
    
Friend WithEvents Label1 As System.Windows.Forms.Label
    
Friend WithEvents Label2 As System.Windows.Forms.Label
    
Friend WithEvents Label3 As System.Windows.Forms.Label
    
Friend WithEvents Label4 As System.Windows.Forms.Label
    
Friend WithEvents Label5 As System.Windows.Forms.Label
    
Friend WithEvents Label6 As System.Windows.Forms.Label
    
Friend WithEvents Label7 As System.Windows.Forms.Label
    
Friend WithEvents Label8 As System.Windows.Forms.Label
    
Friend WithEvents Label9 As System.Windows.Forms.Label
    
Friend WithEvents Label10 As System.Windows.Forms.Label
    
Friend WithEvents Label11 As System.Windows.Forms.Label
    
Friend WithEvents Label12 As System.Windows.Forms.Label
    
Friend WithEvents Label13 As System.Windows.Forms.Label
    
Friend WithEvents Label14 As System.Windows.Forms.Label
    
Friend WithEvents Label15 As System.Windows.Forms.Label
    
Friend WithEvents Label16 As System.Windows.Forms.Label
    
Friend WithEvents Button2 As System.Windows.Forms.Button
    
Friend WithEvents Label17 As System.Windows.Forms.Label
    
Friend WithEvents Label18 As System.Windows.Forms.Label
    
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    
Friend WithEvents Button3 As System.Windows.Forms.Button
    
Friend WithEvents Label19 As System.Windows.Forms.Label
    
Friend WithEvents Label20 As System.Windows.Forms.Label
    
Friend WithEvents Label21 As System.Windows.Forms.Label
    
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    
Friend WithEvents Label22 As System.Windows.Forms.Label
    
Friend WithEvents Button4 As System.Windows.Forms.Button
    
Friend WithEvents Button5 As System.Windows.Forms.Button
    
Friend WithEvents StartButton As System.Windows.Forms.Button
    
Friend WithEvents label23 As System.Windows.Forms.Label
    
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
    
Friend WithEvents Button1 As System.Windows.Forms.Button
    
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        
Me.components = New System.ComponentModel.Container
        
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        
Me.GroupBox1 = New System.Windows.Forms.GroupBox
        
Me.Button5 = New System.Windows.Forms.Button
        
Me.TextBox2 = New System.Windows.Forms.TextBox
        
Me.Label21 = New System.Windows.Forms.Label
        
Me.Label20 = New System.Windows.Forms.Label
        
Me.Label19 = New System.Windows.Forms.Label
        
Me.Button3 = New System.Windows.Forms.Button
        
Me.TextBox1 = New System.Windows.Forms.TextBox
        
Me.TextBox3 = New System.Windows.Forms.TextBox
        
Me.TextBox4 = New System.Windows.Forms.TextBox
        
Me.Button4 = New System.Windows.Forms.Button
        
Me.Label1 = New System.Windows.Forms.Label
        
Me.Label2 = New System.Windows.Forms.Label
        
Me.Label3 = New System.Windows.Forms.Label
        
Me.Label4 = New System.Windows.Forms.Label
        
Me.Label5 = New System.Windows.Forms.Label
        
Me.Label6 = New System.Windows.Forms.Label
        
Me.Label7 = New System.Windows.Forms.Label
        
Me.Label8 = New System.Windows.Forms.Label
        
Me.Label9 = New System.Windows.Forms.Label
        
Me.Label10 = New System.Windows.Forms.Label
        
Me.Label11 = New System.Windows.Forms.Label
        
Me.Label12 = New System.Windows.Forms.Label
        
Me.Label13 = New System.Windows.Forms.Label
        
Me.Label14 = New System.Windows.Forms.Label
        
Me.Label15 = New System.Windows.Forms.Label
        
Me.Label16 = New System.Windows.Forms.Label
        
Me.StartButton = New System.Windows.Forms.Button
        
Me.Button2 = New System.Windows.Forms.Button
        
Me.Label17 = New System.Windows.Forms.Label
        
Me.Label18 = New System.Windows.Forms.Label
        
Me.Label22 = New System.Windows.Forms.Label
        
Me.label23 = New System.Windows.Forms.Label
        
Me.TextBox5 = New System.Windows.Forms.TextBox
        
Me.Button1 = New System.Windows.Forms.Button
        
Me.GroupBox1.SuspendLayout()
        
Me.SuspendLayout()
        
'
        'Timer1
        '
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Button5)
        
Me.GroupBox1.Controls.Add(Me.TextBox2)
        
Me.GroupBox1.Controls.Add(Me.Label21)
        
Me.GroupBox1.Controls.Add(Me.Label20)
        
Me.GroupBox1.Controls.Add(Me.Label19)
        
Me.GroupBox1.Controls.Add(Me.Button3)
        
Me.GroupBox1.Controls.Add(Me.TextBox1)
        
Me.GroupBox1.Controls.Add(Me.TextBox3)
        
Me.GroupBox1.Controls.Add(Me.TextBox4)
        
Me.GroupBox1.Controls.Add(Me.Button4)
        
Me.GroupBox1.Location = New System.Drawing.Point(88)
        
Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(456120)
        
Me.GroupBox1.TabIndex = 0
        
Me.GroupBox1.TabStop = False
        
Me.GroupBox1.Text = "抗生素"
        '
        'Button5
        '
        Me.Button5.Location = New System.Drawing.Point(34424)
        
Me.Button5.Name = "Button5"
        Me.Button5.TabIndex = 8
        
Me.Button5.Text = "Accept"
        '
        'TextBox2
        '
        Me.TextBox2.Enabled = False
        
Me.TextBox2.Location = New System.Drawing.Point(16824)
        
Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(5621)
        
Me.TextBox2.TabIndex = 5
        
Me.TextBox2.Text = ""
        '
        'Label21
        '
        Me.Label21.Location = New System.Drawing.Point(856)
        
Me.Label21.Name = "Label21"
        Me.Label21.Size = New System.Drawing.Size(9624)
        
Me.Label21.TabIndex = 4
        
Me.Label21.Text = "anti-it-number"
        '
        'Label20
        '
        Me.Label20.Location = New System.Drawing.Point(22424)
        
Me.Label20.Name = "Label20"
        Me.Label20.Size = New System.Drawing.Size(5624)
        
Me.Label20.TabIndex = 3
        
Me.Label20.Text = "killrate"
        '
        'Label19
        '
        Me.Label19.Location = New System.Drawing.Point(12824)
        
Me.Label19.Name = "Label19"
        Me.Label19.Size = New System.Drawing.Size(4024)
        
Me.Label19.TabIndex = 2
        
Me.Label19.Text = "area"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(4824)
        
Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(6424)
        
Me.Button3.TabIndex = 1
        
Me.Button3.Text = "Refresh"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(824)
        
Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(3221)
        
Me.TextBox1.TabIndex = 0
        
Me.TextBox1.Text = ""
        '
        'TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(28024)
        
Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(5621)
        
Me.TextBox3.TabIndex = 5
        
Me.TextBox3.Text = ""
        '
        'TextBox4
        '
        Me.TextBox4.Location = New System.Drawing.Point(10456)
        
Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(5621)
        
Me.TextBox4.TabIndex = 5
        
Me.TextBox4.Text = ""
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(16856)
        
Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(8024)
        
Me.Button4.TabIndex = 7
        
Me.Button4.Text = "Drop Med."
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(32144)
        
Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(3232)
        
Me.Label1.TabIndex = 1
        
'
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(72144)
        
Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(3232)
        
Me.Label2.TabIndex = 1
        
'
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(112144)
        
Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(3232)
        
Me.Label3.TabIndex = 1
        
'
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(152144)
        
Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(3232)
        
Me.Label4.TabIndex = 1
        
'
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(32184)
        
Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(3232)
        
Me.Label5.TabIndex = 1
        
'
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(72184)
        
Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(3232)
        
Me.Label6.TabIndex = 1
        
'
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(112184)
        
Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(3232)
        
Me.Label7.TabIndex = 1
        
'
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(152184)
        
Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(3232)
        
Me.Label8.TabIndex = 1
        
'
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(32224)
        
Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(3232)
        
Me.Label9.TabIndex = 1
        
'
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(72224)
        
Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(3232)
        
Me.Label10.TabIndex = 1
        
'
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(112224)
        
Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(3232)
        
Me.Label11.TabIndex = 1
        
'
        'Label12
        '
        Me.Label12.Location = New System.Drawing.Point(152224)
        
Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(3232)
        
Me.Label12.TabIndex = 1
        
'
        'Label13
        '
        Me.Label13.Location = New System.Drawing.Point(32264)
        
Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(3232)
        
Me.Label13.TabIndex = 1
        
'
        'Label14
        '
        Me.Label14.Location = New System.Drawing.Point(72264)
        
Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(3232)
        
Me.Label14.TabIndex = 1
        
'
        'Label15
        '
        Me.Label15.Location = New System.Drawing.Point(112264)
        
Me.Label15.Name = "Label15"
        Me.Label15.Size = New System.Drawing.Size(3232)
        
Me.Label15.TabIndex = 1
        
'
        'Label16
        '
        Me.Label16.Location = New System.Drawing.Point(152264)
        
Me.Label16.Name = "Label16"
        Me.Label16.Size = New System.Drawing.Size(3232)
        
Me.Label16.TabIndex = 1
        
'
        'StartButton
        '
        Me.StartButton.Location = New System.Drawing.Point(384136)
        
Me.StartButton.Name = "StartButton"
        Me.StartButton.Size = New System.Drawing.Size(8024)
        
Me.StartButton.TabIndex = 2
        
Me.StartButton.Text = "Start"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(384168)
        
Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(8024)
        
Me.Button2.TabIndex = 3
        
Me.Button2.Text = "Drop Bact."
        '
        'Label17
        '
        Me.Label17.Location = New System.Drawing.Point(192144)
        
Me.Label17.Name = "Label17"
        Me.Label17.Size = New System.Drawing.Size(6424)
        
Me.Label17.TabIndex = 4
        
Me.Label17.Text = "lastbact"
        '
        'Label18
        '
        Me.Label18.Location = New System.Drawing.Point(264144)
        
Me.Label18.Name = "Label18"
        Me.Label18.Size = New System.Drawing.Size(3232)
        
Me.Label18.TabIndex = 5
        
'
        'Label22
        '
        Me.Label22.Location = New System.Drawing.Point(312136)
        
Me.Label22.Name = "Label22"
        Me.Label22.Size = New System.Drawing.Size(4024)
        
Me.Label22.TabIndex = 6
        
Me.Label22.Text = "Off"
        '
        'label23
        '
        Me.label23.Location = New System.Drawing.Point(192184)
        
Me.label23.Name = "label23"
        Me.label23.Size = New System.Drawing.Size(6432)
        
Me.label23.TabIndex = 7
        
Me.label23.Text = "Bact.Anti-Med.rate"
        '
        'TextBox5
        '
        Me.TextBox5.Location = New System.Drawing.Point(256184)
        
Me.TextBox5.Name = "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(4021)
        
Me.TextBox5.TabIndex = 8
        
Me.TextBox5.Text = "50"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(304184)
        
Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(5624)
        
Me.Button1.TabIndex = 9
        
Me.Button1.Text = "Accept"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(614)
        
Me.ClientSize = New System.Drawing.Size(480334)
        
Me.Controls.Add(Me.Button1)
        
Me.Controls.Add(Me.TextBox5)
        
Me.Controls.Add(Me.label23)
        
Me.Controls.Add(Me.Label22)
        
Me.Controls.Add(Me.Label18)
        
Me.Controls.Add(Me.Label17)
        
Me.Controls.Add(Me.Button2)
        
Me.Controls.Add(Me.StartButton)
        
Me.Controls.Add(Me.Label1)
        
Me.Controls.Add(Me.GroupBox1)
        
Me.Controls.Add(Me.Label2)
        
Me.Controls.Add(Me.Label3)
        
Me.Controls.Add(Me.Label4)
        
Me.Controls.Add(Me.Label5)
        
Me.Controls.Add(Me.Label6)
        
Me.Controls.Add(Me.Label7)
        
Me.Controls.Add(Me.Label8)
        
Me.Controls.Add(Me.Label9)
        
Me.Controls.Add(Me.Label10)
        
Me.Controls.Add(Me.Label11)
        
Me.Controls.Add(Me.Label12)
        
Me.Controls.Add(Me.Label13)
        
Me.Controls.Add(Me.Label14)
        
Me.Controls.Add(Me.Label15)
        
Me.Controls.Add(Me.Label16)
        
Me.Name = "Form1"
        Me.Text = "细菌抗药性模拟器"
        Me.GroupBox1.ResumeLayout(False)
        
Me.ResumeLayout(False)

    
End Sub


#End Region


    
Public Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
        
For i = 0 To 9
            med(i).area 
= 15
            med(i).killrate 
= 70
        
Next
        
For i = 0 To 49
            
ReDim bact(i).antimedicine(10)
            
For Each boi In bact(i).antimedicine
                boi 
= False
            
Next
        
Next
        CurrentMedicine 
= 0
        firstready()
    
End Sub

    
Private Sub firstready()
        clearlabel()
        lastbact 
= 0

    
End Sub

    
Private Sub newbact(ByVal number As Byte)
        
Dim ro As System.Random = New Random
        bact(number).locate.X 
= (ro.Next(04))
        bact(number).locate.Y 
= (ro.Next(04))
        bact(number).alive 
= True
        
For i = 0 To 9
            bact(number).antimedicine(i) 
= False
        
Next
    
End Sub



    
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles StartButton.Click
        Timer1.Interval 
= 20
        Timer1.Enabled 
= True
        Timer1.Start()
        StartButton.Enabled 
= False
        Label22.Text 
= "On"
    End Sub

    
Private Sub printbact(ByVal t As bacteria)
        
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
    
End Sub

    
Private Sub clearlabel()
        Label1.Text 
= "0"
        Label2.Text = "0"
        Label3.Text = "0"
        Label4.Text = "0"
        Label5.Text = "0"
        Label6.Text = "0"
        Label7.Text = "0"
        Label8.Text = "0"
        Label9.Text = "0"
        Label10.Text = "0"
        Label11.Text = "0"
        Label12.Text = "0"
        Label13.Text = "0"
        Label14.Text = "0"
        Label15.Text = "0"
        Label16.Text = "0"
    End Sub


    
Private Sub Timer1_Tick(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Timer1.Tick
        clearlabel()
        Label18.Text 
= Str(lastbact)
        sum 
= 0
        
For Each t In bact
            
If t.alive = True Then
                printbact(t)
                boi 
= True
                
For Each boj In t.antimedicine
                    
If boj = False Then
                        boi 
= False
                        
Exit For
                    
End If
                    
If boi = True Then
                        Timer1.
Stop()
                        Label22.Text 
= "Off"
                        StartButton.Enabled = "True"
                        If MsgBox("Super bacteria appeared!Go on?", MsgBoxStyle.YesNo, "Super bacteria appeared!"= MsgBoxResult.Yes Then
                            Timer1.Start()
                            Label22.Text 
= "On"
                            StartButton.Enabled = False
                        
End If

                        
Exit Sub
                    
End If
                
Next
                sum 
= sum + 1
            
End If
        
Next
        
If sum = 0 And lastbact <> 0 Then
            Timer1.
Stop()
            Label22.Text 
= "Off"
            StartButton.Enabled = True
            
MsgBox("All the bacterium died!")
            
Exit Sub
        
End If
    
End Sub


    
Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button2.Click

        
If lastbact = 50 Then
            
MsgBox("maxium number of bacts!")
        
Else
            lastbact 
= lastbact + 1
            newbact(lastbact 
- 1)
            refleshmap()
        
End If
    
End Sub

    
Private Sub refleshmap()
        clearlabel()
        Label18.Text 
= Str(lastbact)
        
For Each t In bact
            
If t.alive = True Then
                printbact(t)
            
End If
        
Next
    
End Sub


    
Private Sub Button3_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button3.Click
        
If Not (IsNumeric(TextBox1.Text)) Then
            
MsgBox("Must be number!")
        
Else
            
If Int(Val(TextBox1.Text)) <> Val(TextBox1.Text) Then
                
MsgBox("Must be integer!")
            
Else
                
If Val(TextBox1.Text) > 10 Or Val(TextBox1.Text) < 0 Then
                    
MsgBox("Must be more than -1 and less than 11!")
                
Else
                    CurrentMedicine 
= Val(TextBox1.Text)
                    printinfo(CurrentMedicine)
                
End If
            
End If
        
End If
    
End Sub

    
Private Sub printinfo(ByVal i As Short)
        TextBox2.Text 
= med(CurrentMedicine).area
        TextBox3.Text 
= med(CurrentMedicine).killrate
        sum 
= 0
        
For j = 0 To 49
            
If bact(j).alive And bact(j).antimedicine(i) = True Then sum += 1
        
Next
        TextBox4.Text 
= sum
    
End Sub


    
Private Sub Button5_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button5.Click
        
If Not (IsNumeric(TextBox2.Text)) Then
            
MsgBox("Must be number!")
        
Else
            
If Int(Val(TextBox2.Text)) <> Val(TextBox2.Text) Then
                
MsgBox("Must be integer!")
            
Else
                
If Val(TextBox2.Text) > 100 Or Val(TextBox2.Text) < 0 Then
                    
MsgBox("Must be no more than 100 and no less than 0!")
                
Else
                    med(CurrentMedicine).area 
= Val(TextBox2.Text)
                
End If
            
End If
        
End If
        
If Not (IsNumeric(TextBox3.Text)) Then
            
MsgBox("Must be number!")
        
Else
            
If Int(Val(TextBox3.Text)) <> Val(TextBox3.Text) Then
                
MsgBox("Must be integer!")
            
Else
                
If Val(TextBox3.Text) > 100 Or Val(TextBox3.Text) < 0 Then
                    
MsgBox("Must be no more than 100 and no less than 0!")
                
Else
                    med(CurrentMedicine).killrate 
= Val(TextBox3.Text)
                
End If
            
End If
        
End If
    
End Sub


    
Private Sub Button4_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button4.Click
        
For i = 0 To 49
            
If bact(i).alive Then
                
If Not (bact(i).antimedicine(CurrentMedicine)) Then
                    
If rate(med(CurrentMedicine).killrate) Then
                        bact(i).alive 
= False
                    
Else
                        
If rate(BacteriumAntiMedicineRate) Then
                            bact(i).antimedicine(CurrentMedicine) 
= True
                        
End If
                    
End If
                
End If
            
End If
        
Next
        refleshmap()
    
End Sub

    
Private Function rate(ByVal j As ByteAs Boolean
        
If ro.Next(1100<= j Then
            
Return True
        
Else
            
Return False
        
End If
    
End Function


    
Private Sub Button1_Click_1(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click
        
If Not (IsNumeric(TextBox5.Text)) Then
            
MsgBox("Must be number!")
        
Else
            
If Int(Val(TextBox5.Text)) <> Val(TextBox5.Text) Then
                
MsgBox("Must be integer!")
            
Else
                
If Val(TextBox5.Text) > 100 Or Val(TextBox5.Text) < 0 Then
                    
MsgBox("Must be no more than 100 and no less than 0!")
                
Else
                    BacteriumAntiMedicineRate 
= Val(TextBox5.Text)
                
End If
            
End If
        
End If
    
End Sub

End Class


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3