Ensimmäinen Visual Basic.net koodin pätkä.Valmis peli löytyy osoitteesta http://koti.mbnet.fi/ak90/ristinolla.exe
Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. 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 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Button4 As System.Windows.Forms.Button Friend WithEvents Button5 As System.Windows.Forms.Button Friend WithEvents Button6 As System.Windows.Forms.Button Friend WithEvents Button7 As System.Windows.Forms.Button Friend WithEvents Button8 As System.Windows.Forms.Button Friend WithEvents Button9 As System.Windows.Forms.Button Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button10 As System.Windows.Forms.Button Friend WithEvents Button11 As System.Windows.Forms.Button Friend WithEvents Button12 As System.Windows.Forms.Button Friend WithEvents Button13 As System.Windows.Forms.Button Friend WithEvents Button14 As System.Windows.Forms.Button Friend WithEvents Button15 As System.Windows.Forms.Button Friend WithEvents Button16 As System.Windows.Forms.Button Friend WithEvents Button17 As System.Windows.Forms.Button Friend WithEvents Button18 As System.Windows.Forms.Button Friend WithEvents Button19 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label() Me.Button1 = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.Button4 = New System.Windows.Forms.Button() Me.Button5 = New System.Windows.Forms.Button() Me.Button6 = New System.Windows.Forms.Button() Me.Button7 = New System.Windows.Forms.Button() Me.Button8 = New System.Windows.Forms.Button() Me.Button9 = New System.Windows.Forms.Button() Me.Label2 = New System.Windows.Forms.Label() Me.Button10 = New System.Windows.Forms.Button() Me.Button11 = New System.Windows.Forms.Button() Me.Button12 = New System.Windows.Forms.Button() Me.Button13 = New System.Windows.Forms.Button() Me.Button14 = New System.Windows.Forms.Button() Me.Button15 = New System.Windows.Forms.Button() Me.Button16 = New System.Windows.Forms.Button() Me.Button17 = New System.Windows.Forms.Button() Me.Button18 = New System.Windows.Forms.Button() Me.Button19 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Label1 ' Me.Label1.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(224, Byte), CType(192, Byte)) Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label1.Font = New System.Drawing.Font("Lucida Handwriting", 27.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(24, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(456, 56) Me.Label1.TabIndex = 0 Me.Label1.Text = "RISTINOLLA" Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Button1 ' Me.Button1.BackColor = System.Drawing.Color.Lime Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(24, 104) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(100, 100) Me.Button1.TabIndex = 1 ' 'Button2 ' Me.Button2.BackColor = System.Drawing.Color.Lime Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(144, 104) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(100, 100) Me.Button2.TabIndex = 2 ' 'Button3 ' Me.Button3.BackColor = System.Drawing.Color.Lime Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button3.Location = New System.Drawing.Point(264, 104) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(100, 100) Me.Button3.TabIndex = 3 ' 'Button4 ' Me.Button4.BackColor = System.Drawing.Color.Lime Me.Button4.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button4.Location = New System.Drawing.Point(24, 224) Me.Button4.Name = "Button4" Me.Button4.Size = New System.Drawing.Size(100, 100) Me.Button4.TabIndex = 4 ' 'Button5 ' Me.Button5.BackColor = System.Drawing.Color.Lime Me.Button5.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button5.Location = New System.Drawing.Point(144, 224) Me.Button5.Name = "Button5" Me.Button5.Size = New System.Drawing.Size(100, 100) Me.Button5.TabIndex = 5 ' 'Button6 ' Me.Button6.BackColor = System.Drawing.Color.Lime Me.Button6.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button6.Location = New System.Drawing.Point(264, 224) Me.Button6.Name = "Button6" Me.Button6.Size = New System.Drawing.Size(100, 100) Me.Button6.TabIndex = 6 ' 'Button7 ' Me.Button7.BackColor = System.Drawing.Color.Lime Me.Button7.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button7.Location = New System.Drawing.Point(24, 344) Me.Button7.Name = "Button7" Me.Button7.Size = New System.Drawing.Size(100, 100) Me.Button7.TabIndex = 7 ' 'Button8 ' Me.Button8.BackColor = System.Drawing.Color.Lime Me.Button8.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button8.Location = New System.Drawing.Point(144, 344) Me.Button8.Name = "Button8" Me.Button8.Size = New System.Drawing.Size(100, 100) Me.Button8.TabIndex = 8 ' 'Button9 ' Me.Button9.BackColor = System.Drawing.Color.Lime Me.Button9.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button9.Location = New System.Drawing.Point(264, 344) Me.Button9.Name = "Button9" Me.Button9.Size = New System.Drawing.Size(100, 100) Me.Button9.TabIndex = 9 ' 'Label2 ' Me.Label2.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte)) Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(488, 104) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(288, 248) Me.Label2.TabIndex = 18 Me.Label2.Text = "Label2" ' 'Button10 ' Me.Button10.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte)) Me.Button10.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button10.Location = New System.Drawing.Point(528, 440) Me.Button10.Name = "Button10" Me.Button10.Size = New System.Drawing.Size(224, 40) Me.Button10.TabIndex = 19 Me.Button10.Text = "Otetaan uusiksi" ' 'Button11 ' Me.Button11.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte)) Me.Button11.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button11.Location = New System.Drawing.Point(528, 512) Me.Button11.Name = "Button11" Me.Button11.Size = New System.Drawing.Size(224, 40) Me.Button11.TabIndex = 20 Me.Button11.Text = "Blaah tylsää!!" ' 'Button12 ' Me.Button12.BackColor = System.Drawing.Color.Lime Me.Button12.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button12.Location = New System.Drawing.Point(384, 104) Me.Button12.Name = "Button12" Me.Button12.Size = New System.Drawing.Size(100, 100) Me.Button12.TabIndex = 23 ' 'Button13 ' Me.Button13.BackColor = System.Drawing.Color.Lime Me.Button13.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button13.Location = New System.Drawing.Point(384, 224) Me.Button13.Name = "Button13" Me.Button13.Size = New System.Drawing.Size(100, 100) Me.Button13.TabIndex = 24 ' 'Button14 ' Me.Button14.BackColor = System.Drawing.Color.Lime Me.Button14.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button14.Location = New System.Drawing.Point(384, 344) Me.Button14.Name = "Button14" Me.Button14.Size = New System.Drawing.Size(100, 100) Me.Button14.TabIndex = 25 ' 'Button15 ' Me.Button15.BackColor = System.Drawing.Color.Lime Me.Button15.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button15.Location = New System.Drawing.Point(24, 464) Me.Button15.Name = "Button15" Me.Button15.Size = New System.Drawing.Size(100, 100) Me.Button15.TabIndex = 26 ' 'Button16 ' Me.Button16.BackColor = System.Drawing.Color.Lime Me.Button16.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button16.Location = New System.Drawing.Point(144, 464) Me.Button16.Name = "Button16" Me.Button16.Size = New System.Drawing.Size(100, 100) Me.Button16.TabIndex = 27 ' 'Button17 ' Me.Button17.BackColor = System.Drawing.Color.Lime Me.Button17.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button17.Location = New System.Drawing.Point(264, 464) Me.Button17.Name = "Button17" Me.Button17.Size = New System.Drawing.Size(100, 100) Me.Button17.TabIndex = 28 ' 'Button18 ' Me.Button18.BackColor = System.Drawing.Color.Lime Me.Button18.Font = New System.Drawing.Font("Microsoft Sans Serif", 48.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button18.Location = New System.Drawing.Point(384, 464) Me.Button18.Name = "Button18" Me.Button18.Size = New System.Drawing.Size(100, 100) Me.Button18.TabIndex = 29 ' 'Button19 ' Me.Button19.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte)) Me.Button19.Location = New System.Drawing.Point(528, 376) Me.Button19.Name = "Button19" Me.Button19.Size = New System.Drawing.Size(224, 40) Me.Button19.TabIndex = 30 Me.Button19.Text = "Ohjeet" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte)) Me.ClientSize = New System.Drawing.Size(784, 581) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button19, Me.Button18, Me.Button17, Me.Button16, Me.Button15, Me.Button14, Me.Button13, Me.Button12, Me.Button11, Me.Button10, Me.Label2, Me.Button9, Me.Button8, Me.Button7, Me.Button6, Me.Button5, Me.Button4, Me.Button3, Me.Button2, Me.Button1, Me.Label1}) Me.Name = "Form1" Me.Text = "Ristinolla" Me.ResumeLayout(False) End Sub #End Region Dim Merkki As Char Dim Pelaaja As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AloitaUusiPeli() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Button1.Text = Merkki Button1.Enabled = False TarkistaVoittaja() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Button2.Text = Merkki Button2.Enabled = False TarkistaVoittaja() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Button3.Text = Merkki Button3.Enabled = False TarkistaVoittaja() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Button4.Text = Merkki Button4.Enabled = False TarkistaVoittaja() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Button5.Text = Merkki Button5.Enabled = False TarkistaVoittaja() End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Button6.Text = Merkki Button6.Enabled = False TarkistaVoittaja() End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click Button7.Text = Merkki Button7.Enabled = False TarkistaVoittaja() End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click Button8.Text = Merkki Button8.Enabled = False TarkistaVoittaja() End Sub Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Button9.Text = Merkki Button9.Enabled = False TarkistaVoittaja() End Sub Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click Button12.Text = Merkki Button12.Enabled = False TarkistaVoittaja() End Sub Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click Button13.Text = Merkki Button13.Enabled = False TarkistaVoittaja() End Sub Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click Button14.Text = Merkki Button14.Enabled = False TarkistaVoittaja() End Sub Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click Button15.Text = Merkki Button15.Enabled = False TarkistaVoittaja() End Sub Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click Button16.Text = Merkki Button16.Enabled = False TarkistaVoittaja() End Sub Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click Button17.Text = Merkki Button17.Enabled = False TarkistaVoittaja() End Sub Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click Button18.Text = Merkki Button18.Enabled = False TarkistaVoittaja() End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click AloitaUusiPeli() End Sub Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click End End Sub Private Sub SeuraavaPelaaja() If Pelaaja = 1 Then Merkki = "X" Pelaaja = 2 ElseIf Pelaaja = 2 Then Merkki = "0" Pelaaja = 1 End If Label2.Text = "Pelaaja " & Pelaaja & " : ' " & Merkki & " ' " End Sub Private Sub NäytäVoittaja() 'näytä voittoviesti Label2.Text = "pelaaja ' " & Merkki & " ' Hakkasi toisen pelaajan pystyyn!Ottakaa uusinta matsi!!" 'sammuta kaikki napit Button1.Enabled = False Button2.Enabled = False Button3.Enabled = False Button4.Enabled = False Button5.Enabled = False Button6.Enabled = False Button7.Enabled = False Button8.Enabled = False Button9.Enabled = False Button12.Enabled = False Button13.Enabled = False Button14.Enabled = False Button15.Enabled = False Button16.Enabled = False Button17.Enabled = False Button18.Enabled = False End Sub Private Sub TarkistaVoittaja() 'tarkista onko voittorivejä If Len(Button1.Text & Button2.Text & Button3.Text & Button12.Text) = 4 And _ Button1.Text = Button2.Text And Button2.Text = Button3.Text And Button3.Text = Button12.Text Then Button1.BackColor = Color.Yellow Button2.BackColor = Color.Yellow Button3.BackColor = Color.Yellow Button12.BackColor = Color.Yellow NäytäVoittaja() MsgBox("Hah liian helppoa") ElseIf Len(Button4.Text & Button5.Text & Button6.Text & Button13.Text) = 4 And _ Button4.Text = Button5.Text And Button5.Text = Button6.Text And Button6.Text = Button13.Text Then Button4.BackColor = Color.Yellow Button5.BackColor = Color.Yellow Button6.BackColor = Color.Yellow Button13.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button7.Text & Button8.Text & Button9.Text & Button14.Text) = 4 And _ Button7.Text = Button8.Text And Button8.Text = Button9.Text And Button9.Text = Button14.Text Then Button7.BackColor = Color.Yellow Button8.BackColor = Color.Yellow Button9.BackColor = Color.Yellow Button14.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button1.Text & Button4.Text & Button7.Text & Button15.Text) = 4 And _ Button1.Text = Button4.Text And Button4.Text = Button7.Text And Button7.Text = Button15.Text Then Button1.BackColor = Color.Yellow Button4.BackColor = Color.Yellow Button7.BackColor = Color.Yellow Button15.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button2.Text & Button5.Text & Button8.Text & Button16.Text) = 4 And _ Button2.Text = Button5.Text And Button5.Text = Button8.Text And Button8.Text = Button16.Text Then Button2.BackColor = Color.Yellow Button5.BackColor = Color.Yellow Button8.BackColor = Color.Yellow Button16.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button3.Text & Button6.Text & Button9.Text & Button17.Text) = 4 And _ Button3.Text = Button6.Text And Button6.Text = Button9.Text And Button9.Text = Button17.Text Then Button3.BackColor = Color.Yellow Button6.BackColor = Color.Yellow Button9.BackColor = Color.Yellow Button17.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button1.Text & Button5.Text & Button9.Text & Button18.Text) = 4 And _ Button1.Text = Button5.Text And Button5.Text = Button9.Text And Button9.Text = Button18.Text Then Button1.BackColor = Color.Yellow Button5.BackColor = Color.Yellow Button9.BackColor = Color.Yellow Button18.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button1.Text & Button5.Text & Button9.Text & Button18.Text) = 4 And _ Button1.Text = Button5.Text And Button5.Text = Button9.Text And Button9.Text = Button18.Text Then Button1.BackColor = Color.Yellow Button5.BackColor = Color.Yellow Button9.BackColor = Color.Yellow Button18.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button15.Text & Button16.Text & Button17.Text & Button18.Text) = 4 And _ Button15.Text = Button16.Text And Button16.Text = Button17.Text And Button17.Text = Button18.Text Then Button15.BackColor = Color.Yellow Button16.BackColor = Color.Yellow Button17.BackColor = Color.Yellow Button18.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button12.Text & Button6.Text & Button8.Text & Button15.Text) = 4 And _ Button12.Text = Button6.Text And Button6.Text = Button8.Text And Button8.Text = Button15.Text Then Button12.BackColor = Color.Yellow Button6.BackColor = Color.Yellow Button8.BackColor = Color.Yellow Button15.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button12.Text & Button13.Text & Button14.Text & Button18.Text) = 4 And _ Button12.Text = Button13.Text And Button13.Text = Button14.Text And Button14.Text = Button18.Text Then Button12.BackColor = Color.Yellow Button13.BackColor = Color.Yellow Button14.BackColor = Color.Yellow Button18.BackColor = Color.Yellow NäytäVoittaja() ElseIf Len(Button12.Text & Button13.Text & Button14.Text & Button18.Text) = 4 And _ Button12.Text = Button13.Text And Button13.Text = Button14.Text And Button14.Text = Button18.Text Then Button12.BackColor = Color.Yellow Button13.BackColor = Color.Yellow Button14.BackColor = Color.Yellow Button18.BackColor = Color.Yellow NäytäVoittaja() Else SeuraavaPelaaja() End If End Sub Private Sub AloitaUusiPeli() Button1.Enabled = True Button2.Enabled = True Button3.Enabled = True Button4.Enabled = True Button5.Enabled = True Button6.Enabled = True Button7.Enabled = True Button8.Enabled = True Button9.Enabled = True Button12.Enabled = True Button13.Enabled = True Button14.Enabled = True Button15.Enabled = True Button16.Enabled = True Button17.Enabled = True Button18.Enabled = True Button1.Text = "" Button2.Text = "" Button3.Text = "" Button4.Text = "" Button5.Text = "" Button6.Text = "" Button7.Text = "" Button8.Text = "" Button9.Text = "" Button12.Text = "" Button13.Text = "" Button14.Text = "" Button15.Text = "" Button16.Text = "" Button17.Text = "" Button18.Text = "" Button1.BackColor = Color.Lime Button2.BackColor = Color.Lime Button3.BackColor = Color.Lime Button4.BackColor = Color.Lime Button5.BackColor = Color.Lime Button6.BackColor = Color.Lime Button7.BackColor = Color.Lime Button8.BackColor = Color.Lime Button9.BackColor = Color.Lime Button12.BackColor = Color.Lime Button13.BackColor = Color.Lime Button14.BackColor = Color.Lime Button15.BackColor = Color.Lime Button16.BackColor = Color.Lime Button17.BackColor = Color.Lime Button18.BackColor = Color.Lime Pelaaja = 2 Merkki = "0" SeuraavaPelaaja() End Sub Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click MsgBox("Pelin ideana on saada 'X' merkkejä tai '0' merkkejä neljä peräkkäin.Painamalla 'Otetaan uusiksi' peli alkaa alusta.Painamalla 'Blaah tylsää' peli loppuu") End Sub End Class
Antti90 kirjoitti:
Valmis peli löytyy osoitteesta http://koti.mbnet.fi/ak90/ristinolla.exe
eikä löydy...
Eikö noita Buttoneita voisi tehdä indekseillä, ettei tarvitsi kirjoittaa samaa koodia aina niin monta kertaa?
.NET:ssä käsittääkseni ei ole perinteisiä Control Arrayitä, mutta siinä kontrolleja pysty käsitellä jonku collectionin kautta tyyliin muuli.controls("munnappi" & indeksi)
Tällaiset "mun eka koodi jee!" -pätkät voi kyllä suosiolla jättää lähettämättä.
Aihe on jo aika vanha, joten et voi enää vastata siihen.