2019年4月10日 星期三

BinGo



Public Class Form1

    Dim A11, A12, A13, A21, A22, A23, A31, A32, A33 As Integer
    Dim G11, G12, G13, G21, G22, G23, G31, G32, G33 As Integer
    Dim AG As Integer

    Private Sub AG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BAG.Click
        Randomize()

        A11 = Int(Rnd() * 9 + 1)

        Do
            A12 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A12

        Do
            A13 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A13 And A12 <> A13

        Do
            A21 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A21 And A12 <> A21 And A13 <> A21

        Do
            A22 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A22 And A12 <> A22 And A13 <> A22 And A21 <> A22

        Do
            A23 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A23 And A12 <> A23 And A13 <> A23 And A21 <> A23 And A22 <> A23

        Do
            A31 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A31 And A12 <> A31 And A13 <> A31 And A21 <> A31 And A22 <> A31 And A23 <> A31
        Do
            A32 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A32 And A12 <> A32 And A13 <> A32 And A21 <> A32 And A22 <> A32 And A23 <> A32 And A31 <> A32

        Do
            A33 = Int(Rnd() * 9 + 1)
        Loop Until A11 <> A33 And A12 <> A33 And A13 <> A33 And A21 <> A33 And A22 <> A33 And A23 <> A33 And A31 <> A33 And A32 <> A33


        G11 = Int(Rnd() * 9 + 1)

        Do
            G12 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G12

        Do
            G13 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G13 And G12 <> G13

        Do
            G21 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G21 And G12 <> G21 And G13 <> G21

        Do
            G22 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G22 And G12 <> G22 And G13 <> G22 And G21 <> G22

        Do
            G23 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G23 And G12 <> G23 And G13 <> G23 And G21 <> G23 And G22 <> G23

        Do
            G31 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G31 And G12 <> G31 And G13 <> G31 And G21 <> G31 And G22 <> G31 And G23 <> G31

        Do
            G32 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G32 And G12 <> G32 And G13 <> G32 And G21 <> G32 And G22 <> G32 And G23 <> G32 And G31 <> G32

        Do
            G33 = Int(Rnd() * 9 + 1)
        Loop Until G11 <> G33 And G12 <> G33 And G13 <> G33 And G21 <> G33 And G22 <> G33 And G23 <> G33 And G31 <> G33 And G32 <> G33


        BA11.Text = A11
        BA12.Text = A12
        BA13.Text = A13

        BA21.Text = A21
        BA22.Text = A22
        BA23.Text = A23

        BA31.Text = A31
        BA32.Text = A32
        BA33.Text = A33


        BG11.Text = G11
        BG12.Text = G12
        BG13.Text = G13

        BG21.Text = G21
        BG22.Text = G22
        BG23.Text = G23

        BG31.Text = G31
        BG32.Text = G32
        BG33.Text = G33

    End Sub

End Class

1 則留言: