# Shkenca > Informatikë dhe Internet > Arti i programimit >  Programim në Visual Basic 6.0 & VB 2008

## ViRuSi_ZeRo

Po e hap kete tem per te ndimuar njeri-tjetrin,kushdo qe ka deshir te mesoj visual basic apo apo di ta perdor pak,edhe has ndonje veshtirsi gjat ndonje programimi.., ti vijm ne ndim te gjith se bashku.. :buzeqeshje: 


Visual Basic  2008  ( Loje )  "loja ka si synim te arish te besh tre ''O'' ose "X" horizontalisht,vertikalisht edhe diagonalet (besoj se keni luajtur te gjith me kete loj  :buzeqeshje:  )


```

Public Class form1
    Dim turn As Integer
    Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        turn = 1
    End Sub
    Private Sub win()
        If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
            MsgBox("Lojtari O Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        End If
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Label6.Text = 0
        Label7.Text = 0
        Call OnE()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If turn = 1 Then
            Button1.Text = "O"
            Label2.Text = "X"
        Else
            Button1.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button1.Enabled = False
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If turn = 1 Then
            Button2.Text = "O"
            Label2.Text = "X"
        Else
            Button2.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button2.Enabled = False
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If turn = 1 Then
            Button3.Text = "O"
            Label2.Text = "X"
        Else
            Button3.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button3.Enabled = False
    End Sub
    Private Sub Button4_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        If turn = 1 Then
            Button4.Text = "O"
            Label2.Text = "X"
        Else
            Button4.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button4.Enabled = False
    End Sub

    Private Sub Button5_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        If turn = 1 Then
            Button5.Text = "O"
            Label2.Text = "X"
        Else
            Button5.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button5.Enabled = False
    End Sub
    Private Sub Button6_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
        If turn = 1 Then
            Button6.Text = "O"
            Label2.Text = "X"
        Else
            Button6.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button6.Enabled = False
    End Sub

    Private Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
        If turn = 1 Then
            Button7.Text = "O"
            Label2.Text = "X"
        Else
            Button7.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button7.Enabled = False
    End Sub

    Private Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
        If turn = 1 Then
            Button8.Text = "O"
            Label2.Text = "X"
        Else
            Button8.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button8.Enabled = False
    End Sub

    Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
        If turn = 1 Then
            Button9.Text = "O"
            Label2.Text = "X"
        Else
            Button9.Text = "X"
            Label2.Text = "O"
        End If
        turn += 1
        If turn > 2 Then
            turn = 1
        End If
        Call win()
        Button9.Enabled = False
    End Sub

    Private Sub Button10_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button10.Click
        Call OnE()
    End Sub
    Private Sub ZeRo()
        Button1.Text = ""
        Button1.Enabled = False
        Button2.Text = ""
        Button2.Enabled = False
        Button3.Text = ""
        Button3.Enabled = False
        Button4.Text = ""
        Button4.Enabled = False
        Button5.Text = ""
        Button5.Enabled = False
        Button6.Text = ""
        Button6.Enabled = False
        Button7.Text = ""
        Button7.Enabled = False
        Button8.Text = ""
        Button8.Enabled = False
        Button9.Text = ""
        Button9.Enabled = False
    End Sub
    Private Sub OnE()
        Button1.Text = ""
        Button1.Enabled = True
        Button2.Text = ""
        Button2.Enabled = True
        Button3.Text = ""
        Button3.Enabled = True
        Button4.Text = ""
        Button4.Enabled = True
        Button5.Text = ""
        Button5.Enabled = True
        Button6.Text = ""
        Button6.Enabled = True
        Button7.Text = ""
        Button7.Enabled = True
        Button8.Text = ""
        Button8.Enabled = True
        Button9.Text = ""
        Button9.Enabled = True
    End Sub
End Class
```

----------


## hot_prinz

shume mire, 
tani programo ashtu qe njeri prej lojtarve mund te jete kompjuteri dhe loja do te beje edhe me shume qejf.

----------


## ViRuSi_ZeRo

ketu esht ndertuar loja nji user qe luan me kompjuterin (Loja qe eshte publikuar pak me lart qe luhet nga dy lojtar, Ketu luhet me kompjuterin... :buzeqeshje:  shpresoj tju pelqej),Loja mund te ket gabime sepse nuk e kam testuar  (s'kam sh koh jam me sezon provimesh  :buzeqeshje:   :buzeqeshje:   gjithsesi kjo esht idja per te ndertuar  






```
Public Class form1
    Dim turn As Integer
    Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        turn = 1
    End Sub
    Private Sub win()
        If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
            MsgBox("Lojtari X  Fitoi ")
            Label6.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
            MsgBox("Lojtari O  Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
            MsgBox("Lojtari O Fitoi ")
            Label7.Text += 1
            Call ZeRo()
        End If
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Label6.Text = 0
        Label7.Text = 0
        Call OnE()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Text = "O"
        Button1.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Button2.Text = "O"
        Button2.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Button3.Text = "O"
        Button3.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub
    Private Sub Button4_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        Button4.Text = "O"
        Button4.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub

    Private Sub Button5_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        Button5.Text = "O"
        Button5.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub
    Private Sub Button6_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
        Button6.Text = "O"
        Button6.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub

    Private Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
        Button7.Text = "O"
        Button7.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub

    Private Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
        Button8.Text = "O"
        Button8.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub

    Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
        Button9.Text = "O"
        Button9.Enabled = False
        Call win()
        Call test2()
        Call win()
    End Sub

    Private Sub Button10_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button10.Click
        Call OnE()
    End Sub
    Private Sub ZeRo()
        Button1.Text = ""
        Button1.Enabled = False
        Button2.Text = ""
        Button2.Enabled = False
        Button3.Text = ""
        Button3.Enabled = False
        Button4.Text = ""
        Button4.Enabled = False
        Button5.Text = ""
        Button5.Enabled = False
        Button6.Text = ""
        Button6.Enabled = False
        Button7.Text = ""
        Button7.Enabled = False
        Button8.Text = ""
        Button8.Enabled = False
        Button9.Text = ""
        Button9.Enabled = False
    End Sub
    Private Sub OnE()
        Button1.Text = ""
        Button1.Enabled = True
        Button2.Text = ""
        Button2.Enabled = True
        Button3.Text = ""
        Button3.Enabled = True
        Button4.Text = ""
        Button4.Enabled = True
        Button5.Text = ""
        Button5.Enabled = True
        Button6.Text = ""
        Button6.Enabled = True
        Button7.Text = ""
        Button7.Enabled = True
        Button8.Text = ""
        Button8.Enabled = True
        Button9.Text = ""
        Button9.Enabled = True
    End Sub
    Private Sub test2()
        'ketu fillon testimi i x-ve
        If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "" Then
            Button3.Text = "X"
            Button3.Enabled = False
        ElseIf Button9.Text = "O" And Button5.Enabled = False And Button8.Enabled = True Then
            Button8.Text = "X"
            Button8.Enabled = False
            'kalimi ne nivel 
            'kalimi ne nivel 
        ElseIf Button1.Text = "O" And Button5.Enabled = False And Label7.Text >= 1 And Button8.Text = "O" And Button4.Enabled = True And Button2.Enabled = True And Button3.Enabled = True And Button6.Enabled = True And Button9.Enabled = True Then
            Button7.Text = "X"
            Button7.Enabled = False
            'maron testimi ne livel 
            'fillon testimi i livelit 
        ElseIf Button3.Text = "O" And Button4.Text = "O" And Button5.Enabled = False And Label7.Text >= 2 Then
            Button1.Text = "X"
            Button1.Enabled = False
        
            'mbaron testimi i livelit  kjo loj esht krijuar nga (endri) ose ZeRo & OnE

        ElseIf Button2.Text = "X" And Button3.Text = "X" And Button1.Text = "" Then
            Button1.Text = "X"
            Button1.Enabled = False
        ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "" Then
            Button6.Text = "X"
            Button6.Enabled = False
        ElseIf Button5.Text = "X" And Button6.Text = "X" And Button4.Text = "" Then
            Button4.Text = "X"
            Button4.Enabled = False
        ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "" Then
            Button9.Text = "X"
            Button9.Enabled = False
        ElseIf Button8.Text = "X" And Button9.Text = "X" And Button7.Text = "" Then
            Button7.Text = "X"
            Button7.Enabled = False
        ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "" Then
            Button7.Text = "X"
            Button7.Enabled = False
        ElseIf Button4.Text = "X" And Button7.Text = "X" And Button1.Text = "" Then
            Button1.Text = "X"
            Button1.Enabled = False
        ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "" Then
            Button8.Text = "X"
            Button8.Enabled = False
        ElseIf Button5.Text = "X" And Button8.Text = "X" And Button2.Text = "" Then
            Button2.Text = "X"
            Button2.Enabled = False
        ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "" Then
            Button9.Text = "X"
            Button9.Enabled = False
        ElseIf Button6.Text = "X" And Button9.Text = "X" And Button3.Text = "" Then
            Button3.Text = "X"
            Button3.Enabled = False
        ElseIf Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "" Then
            Button9.Text = "X"
            Button9.Enabled = False
        ElseIf Button7.Text = "X" And Button5.Text = "X" And Button3.Text = "" Then
            Button3.Text = "X"
            Button3.Enabled = False
        ElseIf Button9.Text = "X" And Button5.Text = "X" And Button1.Text = "" Then
            Button1.Text = "X"
            Button1.Enabled = False
        ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "" Then
            Button7.Text = "X"
            Button7.Enabled = False
        ElseIf Button3.Text = "X" And Button1.Text = "X" And Button2.Text = "" Then
            Button2.Text = "X"
            Button2.Enabled = False
        ElseIf Button3.Text = "X" And Button9.Text = "X" And Button6.Text = "" Then
            Button6.Text = "X"
            Button6.Enabled = False
        ElseIf Button9.Text = "X" And Button7.Text = "X" And Button8.Text = "" Then
            Button8.Text = "X"
            Button8.Enabled = False
        ElseIf Button7.Text = "X" And Button1.Text = "X" And Button4.Text = "" Then
            Button4.Text = "X"
            Button4.Enabled = False
            'mbaroi testimi i 2 x-ve
            'filloi testimi i 2 o-ve
        ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Enabled = True Then
            Button3.Text = "X"
            Button3.Enabled = False
        ElseIf Button2.Text = "O" And Button3.Text = "O" And Button1.Enabled = True Then
            Button1.Text = "X"
            Button1.Enabled = False
        ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Enabled = True Then
            Button6.Text = "X"
            Button6.Enabled = False
        ElseIf Button5.Text = "O" And Button6.Text = "O" And Button4.Enabled = True Then
            Button4.Text = "X"
            Button4.Enabled = False
        ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Enabled = True Then
            Button9.Text = "X"
            Button9.Enabled = False
        ElseIf Button8.Text = "O" And Button9.Text = "O" And Button7.Enabled = True Then
            Button7.Text = "X"
            Button7.Enabled = False
        ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Enabled = True Then
            Button7.Text = "X"
            Button7.Enabled = False
        ElseIf Button4.Text = "O" And Button7.Text = "O" And Button1.Enabled = True Then
            Button1.Text = "X"
            Button1.Enabled = False
        ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Enabled = True Then
            Button8.Text = "X"
            Button8.Enabled = False
        ElseIf Button5.Text = "O" And Button8.Text = "O" And Button2.Enabled = True Then
            Button2.Text = "X"
            Button2.Enabled = False
        ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Enabled = True Then
            Button9.Text = "X"
            Button9.Enabled = False
        ElseIf Button6.Text = "O" And Button9.Text = "O" And Button3.Enabled = True Then
            Button3.Text = "X"
            Button3.Enabled = False
        ElseIf Button1.Text = "O" And Button5.Text = "O" And Button9.Enabled = True Then
            Button9.Text = "X"
            Button9.Enabled = False
        ElseIf Button7.Text = "O" And Button5.Text = "O" And Button3.Enabled = True Then
            Button3.Text = "X"
            Button3.Enabled = False
        ElseIf Button9.Text = "O" And Button5.Text = "O" And Button1.Enabled = True Then
            Button1.Text = "X"
            Button1.Enabled = False
        ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Enabled = True Then
            Button7.Text = "X"
            Button7.Enabled = False
        ElseIf Button1.Text = "O" And Button3.Text = "O" And Button2.Enabled = True Then
            Button2.Text = "X"
            Button2.Enabled = False
        ElseIf Button9.Text = "O" And Button3.Text = "O" And Button6.Enabled = True Then
            Button6.Text = "X"
            Button6.Enabled = False
        ElseIf Button9.Text = "O" And Button7.Text = "O" And Button8.Enabled = True Then
            Button8.Text = "X"
            Button8.Enabled = False
        ElseIf Button7.Text = "O" And Button1.Text = "O" And Button4.Enabled = True Then
            Button4.Text = "X"
            Button4.Enabled = False
            'mbaron testimi i 2o-ve
            'test 1o
        ElseIf Button1.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
        ElseIf Button2.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
        ElseIf Button3.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
        ElseIf Button4.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
        ElseIf Button5.Text = "O" Then
            Button1.Text = "X"
            Button1.Enabled = False
        ElseIf Button6.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
        ElseIf Button7.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
        ElseIf Button8.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
        ElseIf Button9.Text = "O" And Button5.Enabled = True Then
            Button5.Text = "X"
            Button5.Enabled = False
            'mbaroi testimi i o
        ElseIf Button1.Text = "O" And Button5.Enabled = False And Button2.Enabled = True Then
            Button2.Text = "X"
            Button2.Enabled = False
        ElseIf Button2.Text = "O" And Button5.Enabled = False And Button3.Enabled = True Then
            Button3.Text = "X"
            Button3.Enabled = False
        ElseIf Button3.Text = "O" And Button5.Enabled = False And Button6.Enabled = True Then
            Button6.Text = "X"
            Button6.Enabled = False
        ElseIf Button6.Text = "O" And Button5.Enabled = False And Button9.Enabled = True Then
            Button9.Text = "X"
            Button9.Enabled = False
        ElseIf Button9.Text = "O" And Button5.Enabled = False And Button8.Enabled = True Then
            Button8.Text = "X"
            Button8.Enabled = False
        ElseIf Button8.Text = "O" And Button5.Enabled = False And Button7.Enabled = True Then
            Button7.Text = "X"
            Button7.Enabled = False
        ElseIf Button7.Text = "O" And Button5.Enabled = False And Button4.Enabled = True Then
            Button4.Text = "X"
            Button4.Enabled = False
        ElseIf Button4.Text = "O" And Button5.Enabled = False And Button1.Enabled = True Then
            Button1.Text = "X"
            Button1.Enabled = False
            'mbaroi testimi i 1o
        End If
    End Sub

End Class
```

----------


## Dito

Nese je i afte ne gjuhen e programimit une mund te ofroj nje pune shume te mire dhe fitim goxha te majme, por nese me thua po, duhet te mos me zhgenjesh me sisteme elementare dhe module te gatshme pasi ajo cka do kerkoj nga ju eshte ngritja e moduleve nga e para te bashkangjitur me kode te nje sistemi grafik. pres nje pergjigje.


*Dito.*

----------


## little-boy

Virus Zero, 

si quhen butonat  "Vazhdo Lojen "  dhe "Loj E re"

----------


## ViRuSi_ZeRo

I ke edhe te figura te shpjeguara pak me lart ,buton vazhdo lojen esht ( button10 ) buton loj e re ( button11 )

----------


## Ardi_Pg_ID

Dito beje publike kete kerkese se ka shume cuna ne forum qe dine te programojne shume shume shume mire hot_princ uke_topalli edspace gepardi etj etj mbase ju hyn atyre e ndonje tjetri ne pune kjo oferte.

Ardi

----------


## Uke Topalli

Pasi qe e kisha diten me pak te ngarkuar vendosa ta bej lojen per dy lojtar ne WPF. WPF eshte shkurtese per Windows Presentation Foundation dhe krijon mundesi qe shtresa e paraqitjes te jet ca me funksionale dhe e zbukuruar. Ne foto shihet pamja e programit. Ndersa programi mund te instalohet nga skedaret qe mund te zbriten nga 
http://rapidshare.com/files/194027508/GameTest.zip.html
(rapidshare njoftoi se vetem dhjet persona mund ta zbresin, nese tejkalohet ky numer dhe ende keni deshire me e instalu dergoni nje mp dhe une do tju dergoj programin)

----------


## hot_prinz

> ketu esht ndertuar loja nji user qe luan me kompjuterin (Loja qe eshte publikuar pak me lart qe luhet nga dy lojtar, Ketu luhet me kompjuterin... shpresoj tju pelqej),Loja mund te ket gabime sepse nuk e kam testuar  (s'kam sh koh jam me sezon provimesh    gjithsesi kjo esht idja per te ndertuar  
> 
> 
> 
> 
> 
> 
> ```
> Public Class form1
> ...


ideja nuk eshte e keqe si fillim, por menyra statike e perdorimit te elementeve(ne kete rast butonave)  me If.. and..and..and..and, elseif ..and..and ..and...., ben te pamundur parashikimin dhe llogaritje e te gjitha mundesive ne te gjitha drejtimet e mundshme.

Po i bashkangjis dy fotografi me numra ne butona, ngjyra e kalter per levizjet e lojtarit dhe ngjyra e kuqe per levizjet e kompjuterit, ne foton e pare kompjuteri nuk arrin te ndaloje lojtarin te fitoje dhe ne fotografine e dyte nuk arrin vete te fitoje duke bere levizje te gabuara. 

Provoje, levizjet jane gjithmone te njejta dhe nese leviz me lojtarin me numrat e kalter loja gjithmone do mbaroje njejte.

----------


## hot_prinz

@Ardi 

falemnderit per at nder, ka vlere te madh per shak te nderit te ndersjellte, e per radhitjen e cunave qe programojne besoj se ia ke fillu listes nga fundi  :buzeqeshje: . 
Sa i perket ofertave ne pergjithesi nuk u them jo, por vetem nese oferta per mua nuk u prish biznise tjerve.


Tani po vendosi nje version te "Tik Tak Toe" ne C#, per llogaritjen e mundesive ne drejtimet e ndryshme perdor nje "jagged_array" (matrice asimetrike, nuk e di si quhet ne gjuhen shqipe) poashtu edhe butonat krijohen ne menyre dinamike ne kete menyre eleminohet statika dhe kodi i perseritshem i butonave, levizjet e kompjuterit jane te rastesishme vetem nese kutija e mesit eshte e zbrazet atehere fillon aty, kjo per te zvogluar mundesite e fitimit lojtarit.



```

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TicTacToe
{
    public partial class Form1 : Form
    {
        Random rnd = new Random();
        bool loja_perfundoi;
        string radha_lojtarit = String.Empty;
        string strLojtari = String.Empty;
        string[][] radhaArray;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            inicializo_lojen();
        }

        private void inicializo_lojen()
        {
            inicializo_butonat();
            inicializo_matricen();
            radha_lojtarit = "Lojtari";
            loja_perfundoi = false;
            loz();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            vizato(34, 135, 303, 135);
            vizato(34, 228, 303, 228);
            vizato(122, 47, 122, 316);
            vizato(215, 47, 215, 316);
        }

        private void vizato(int p, int p_2, int p_3, int p_4)
        {
            System.Drawing.Pen lapsi_im;
            lapsi_im = new System.Drawing.Pen(System.Drawing.Color.Black, 2);
            System.Drawing.Graphics grafika_formes = this.CreateGraphics();
            grafika_formes.DrawLine(lapsi_im, p, p_2, p_3, p_4);
            lapsi_im.Dispose();
            grafika_formes.Dispose();
        }

        private void loz()
        {
            if (!loja_perfundoi)
            {
                if (radha_lojtarit == "Kompjuteri")
                {
                    strLojtari = "O";
                    kontrollo_potezin();
                    kontrollo_rezultatin();
                    radha_lojtarit = "Lojtari";
                }
            }
        }

        private void inicializo_matricen()
        {
            radhaArray = new string[8][];

            radhaArray[0] = new string[3] { "b0", "b1", "b2" };
            radhaArray[1] = new string[3] { "b3", "b4", "b5" };
            radhaArray[2] = new string[3] { "b6", "b7", "b8" };
            radhaArray[3] = new string[3] { "b0", "b3", "b6" };
            radhaArray[4] = new string[3] { "b1", "b4", "b7" };
            radhaArray[5] = new string[3] { "b2", "b5", "b8" };
            radhaArray[6] = new string[3] { "b0", "b4", "b8" };
            radhaArray[7] = new string[3] { "b2", "b4", "b6" };
        }

        private void inicializo_butonat()
        {
            int x = 34; int y = 47;
            int z = 0;
            for (int i = 0; i < 9; i++)
            {
                if (z <= 2)
                {
                    krijo_butonat(x, y, i); x += 92; z++;
                }
                else
                {
                    y += 92;x = 34;z = 0;i--;
                }
            }
        }

        private void krijo_butonat(int x, int y, int i)
        {
            Button b = new Button();
            b.Name = "b" + i.ToString();
            b.Text = String.Empty;
            b.BackColor = Color.Transparent;
            b.FlatAppearance.BorderSize = 0;
            b.FlatStyle = FlatStyle.Flat;
            b.Size = new Size(85, 85);
            b.TextAlign = ContentAlignment.MiddleCenter;
            FontFamily fontFamily = new FontFamily("Arial");
            Font f = new Font(fontFamily, 55, FontStyle.Bold, GraphicsUnit.Pixel);
            b.Font = f;
            b.Anchor = (AnchorStyles.Left);
            b.Location = new Point(x, y);
            b.Click += new System.EventHandler(this.b_Click);
            this.Controls.Add(b);
        }

        private void b_Click(object sender, System.EventArgs e)
        {
            Button butoni_shtypur = (Button)sender;

            if (!loja_perfundoi)
            {
                if (butoni_shtypur.Text == String.Empty)
                {
                    if (radha_lojtarit == "Lojtari")
                    {
                        strLojtari = "X";
                        butoni_shtypur.Text = strLojtari;
                        kontrollo_rezultatin();
                        radha_lojtarit = "Kompjuteri";
                        loz();
                    }
                }
            }
        }

        private void kontrollo_potezin()
        {
            ArrayList vek_empty = new ArrayList();
            bool loz = false;
            bool lojtari_avantazh = false;
            bool kompjuteri_avantazh = false;

            for (int i = 0; i < radhaArray.GetLength(0); i++)
            {
                int y = 0;
                int w = 0;

                if (!loz)
                {
                    for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                    {
                        if (this.Controls[radhaArray[i][j]].Text == "X")
                            y++;
                        else if (this.Controls[radhaArray[i][j]].Text == "O")
                            w++;
                    }

                    if (w == 2 && y == 0)
                        kompjuteri_avantazh = true;
                    else if (y == 2 && w == 0)
                        lojtari_avantazh = true;
                }
            }

            if (kompjuteri_avantazh)
            {
                for (int i = 0; i < radhaArray.GetLength(0); i++)
                {
                    int y = 0;
                    int w = 0;

                    if (!loz)
                    {
                        for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                        {
                            if (this.Controls[radhaArray[i][j]].Text == "X")
                                y++;
                            else if (this.Controls[radhaArray[i][j]].Text == "O")
                                w++;
                        }
                        if (w == 2 && y == 0)
                        {
                            for (int z = 0; z < radhaArray[i].GetLength(0); z++)
                            {
                                if (this.Controls[radhaArray[i][z]].Text != "O")
                                {
                                    this.Controls[radhaArray[i][z]].Text = strLojtari;
                                    loz = true;
                                }
                            }
                        }
                    }
                }
            }
            else if (lojtari_avantazh)
            {
                for (int i = 0; i < radhaArray.GetLength(0); i++)
                {
                    int y = 0;
                    int w = 0;

                    if (!loz)
                    {
                        for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                        {
                            if (this.Controls[radhaArray[i][j]].Text == "X")
                                y++;
                            else if (this.Controls[radhaArray[i][j]].Text == "O")
                                w++;
                        }
                        if (y == 2 && w == 0)
                        {
                            for (int z = 0; z < radhaArray[i].GetLength(0); z++)
                            {
                                if (this.Controls[radhaArray[i][z]].Text != "X")
                                {
                                    this.Controls[radhaArray[i][z]].Text = strLojtari;
                                    loz = true;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                    if (this.Controls["b4"].Text == String.Empty)
                    {
                        this.Controls["b4"].Text = strLojtari;
                        loz = true;
                    }
                    else
                    {
                        for (int m = 0; m < radhaArray.GetLength(0); m++)
                        {
                            for (int n = 0; n < radhaArray[m].GetLength(0); n++)
                            {
                                if (this.Controls[radhaArray[m][n]].Text == String.Empty)
                                {
                                    vek_empty.Add(this.Controls[radhaArray[m][n]].Name.ToString());
                                }
                            }
                        }
                        if (!loz)
                        {
                            if (vek_empty.Count > 0)
                            {
                                int numri_random = rnd.Next(0, vek_empty.Count);
                                this.Controls[vek_empty[numri_random].ToString()].Text = strLojtari;
                                loz = true;
                            }
                        }
                    }
                
            }
        }

        private void kontrollo_rezultatin()
        {
            for (int i = 0; i < radhaArray.GetLength(0); i++)
            {
                int y = 0;
                for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                {
                    if (this.Controls[radhaArray[i][j]].Text == strLojtari)
                        y++;
                    if (y == 3)
                    {
                        lstRezultatet.Items.Add("Fitues " + radha_lojtarit);
                        loja_perfundoi = true;
                        MessageBox.Show("Fitues " + radha_lojtarit, "Informacion!",
                            MessageBoxButtons.OK,MessageBoxIcon.Information);
                    }
                }
            }
        }

        private void LojeRe_Click(object sender, EventArgs e)
        {
            pastrimi_kimik();
            inicializo_lojen();
        }
        private void pastrimi_kimik()
        {
            List<Control> zhdukiButonat = new List<Control>(); 
            foreach (Control c in this.Controls) 
            {
                if (c is Button) 
                {
                    if (c.Name.Substring(0, 1) == "b")
                    {
                        zhdukiButonat.Add(c);
                    }
                } 
            }
            foreach (Control remove in zhdukiButonat)
            {
                this.Controls.Remove(remove);
                remove.Dispose();
            }
        }

        private void FshijRezultatin_Click(object sender, EventArgs e)
        {
            lstRezultatet.Items.Clear();
        }
    }
} 



```

Nuk e ka grafiken te mire si ajo e Ukes por edhe une nuk e lashe pa u munduar  :buzeqeshje:

----------


## hot_prinz

Harrova te postoj projektin per Visual Studio 2008 dhe Aplikacionin per ata qe kane .NET framework 3.5.

----------


## hot_prinz

pasi qe me doli koha e ndryshova kodin duke i hiqur messageboxin kur loja fitohet se mu duk i bezdishem dhe radhitja e fitores tani ngjyrose me te kalter per lojtarin dhe me te kuqe per kompjuterin, poashtu edhe menyren e lojes e ndryshova ne ate te lehte dhe te veshtire:
 - Ne menyren e lehte kompjuteri zgjedh kutine ratesisht dhe pengon lojtarin vetem atehere kur ka dy simbole ne nje rradhe.
 - Ne ate te veshtiren, kompjuteri tenton gjithmone te okupoje kutine e mesit, tjeter kompjuteri llogarit ne rastet kur lojtari nuk ka dy simbole ne nje rresht dhe tenton te kaloje ne ofenzive duke kerkuar mundesine kur ne nje rresht ekziston nje simbol i kompjuterit dhe dy kutite tjera jane te zbrazeta qe njeren kuti te zbrazte te vendose simbolin e tij duke krijuar dy simbole ne nje rresht.

Per te dy menyrat e lojes ekziston nga nje tabele e rezultateve, momentalisht te dyja fshihen pernjehere. 



```

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TicTacToe
{
    public partial class Form1 : Form
    {
        bool modi_lojes;
        Random rnd = new Random();
        bool loja_perfundoi;
        string radha_lojtarit = String.Empty;
        string strLojtari = String.Empty;
        string[][] radhaArray;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            rLehte.Checked = true;
            inicializo_lojen();
        }

        private void inicializo_lojen()
        {
            if (rLehte.Checked == true)
                modi_lojes = true;
            else if (rVeshtire.Checked == true)
                modi_lojes = false;

            inicializo_butonat();
            inicializo_matricen();
            radha_lojtarit = "Lojtari";
            loja_perfundoi = false;
            loz();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            vizato(34, 135, 303, 135);
            vizato(34, 228, 303, 228);
            vizato(122, 47, 122, 316);
            vizato(215, 47, 215, 316);
        }

        private void vizato(int p, int p_2, int p_3, int p_4)
        {
            System.Drawing.Pen lapsi_im;
            lapsi_im = new System.Drawing.Pen(System.Drawing.Color.Black, 2);
            System.Drawing.Graphics grafika_formes = this.CreateGraphics();
            grafika_formes.DrawLine(lapsi_im, p, p_2, p_3, p_4);
            lapsi_im.Dispose();
            grafika_formes.Dispose();
        }

        private void loz()
        {
            if (!loja_perfundoi)
            {
                if (radha_lojtarit == "Kompjuteri")
                {
                    strLojtari = "O";
                    kontrollo_potezin();
                    kontrollo_rezultatin();
                    radha_lojtarit = "Lojtari";
                }
            }
        }

        private void inicializo_matricen()
        {
            radhaArray = new string[8][];

            radhaArray[0] = new string[3] { "b0", "b1", "b2" };
            radhaArray[1] = new string[3] { "b3", "b4", "b5" };
            radhaArray[2] = new string[3] { "b6", "b7", "b8" };
            radhaArray[3] = new string[3] { "b0", "b3", "b6" };
            radhaArray[4] = new string[3] { "b1", "b4", "b7" };
            radhaArray[5] = new string[3] { "b2", "b5", "b8" };
            radhaArray[6] = new string[3] { "b0", "b4", "b8" };
            radhaArray[7] = new string[3] { "b2", "b4", "b6" };
        }

        private void inicializo_butonat()
        {
            int x = 34; int y = 47;
            int z = 0;
            for (int i = 0; i < 9; i++)
            {
                if (z <= 2)
                {
                    krijo_butonat(x, y, i); x += 92; z++;
                }
                else
                {
                    y += 92;x = 34;z = 0;i--;
                }
            }
        }

        private void krijo_butonat(int x, int y, int i)
        {
            Button b = new Button();
            b.Name = "b" + i.ToString();
            b.Text = String.Empty;
            b.BackColor = Color.Transparent;
            b.FlatAppearance.BorderSize = 0;
            b.FlatStyle = FlatStyle.Flat;
            b.Size = new Size(85, 85);
            b.TextAlign = ContentAlignment.MiddleCenter;
            FontFamily fontFamily = new FontFamily("Arial");
            Font f = new Font(fontFamily, 55, FontStyle.Bold, GraphicsUnit.Pixel);
            b.Font = f;
            b.Anchor = (AnchorStyles.Left);
            b.Location = new Point(x, y);
            b.Click += new System.EventHandler(this.b_Click);
            this.Controls.Add(b);
        }

        private void b_Click(object sender, System.EventArgs e)
        {
            Button butoni_shtypur = (Button)sender;

            if (!loja_perfundoi)
            {
                if (butoni_shtypur.Text == String.Empty)
                {
                    if (radha_lojtarit == "Lojtari")
                    {
                        strLojtari = "X";
                        butoni_shtypur.Text = strLojtari;
                        kontrollo_rezultatin();
                        radha_lojtarit = "Kompjuteri";
                        loz();
                    }
                }
            }
        }

        private void kontrollo_potezin()
        {
            ArrayList vek_empty = new ArrayList();
            bool loz = false;
            bool lojtari_avantazh = false;
            bool kompjuteri_avantazh = false;
            bool kompjuteri_perparesi = false;

            for (int i = 0; i < radhaArray.GetLength(0); i++)
            {
                int y = 0;
                int w = 0;

                if (!loz)
                {
                    for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                    {
                        if (this.Controls[radhaArray[i][j]].Text == "X")
                            y++;
                        else if (this.Controls[radhaArray[i][j]].Text == "O")
                            w++;
                    }

                    if (w == 2 && y == 0)
                        kompjuteri_avantazh = true;
                    else if (y == 2 && w == 0)
                        lojtari_avantazh = true;
                }
            }

            if (kompjuteri_avantazh)
            {
                for (int i = 0; i < radhaArray.GetLength(0); i++)
                {
                    int y = 0;
                    int w = 0;

                    if (!loz)
                    {
                        for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                        {
                            if (this.Controls[radhaArray[i][j]].Text == "X")
                                y++;
                            else if (this.Controls[radhaArray[i][j]].Text == "O")
                                w++;
                        }
                        if (w == 2 && y == 0)
                        {
                            for (int z = 0; z < radhaArray[i].GetLength(0); z++)
                            {
                                if (this.Controls[radhaArray[i][z]].Text != "O")
                                {
                                    this.Controls[radhaArray[i][z]].Text = strLojtari;
                                    loz = true;
                                }
                            }
                        }
                    }
                }
            }
            else if (lojtari_avantazh)
            {
                for (int i = 0; i < radhaArray.GetLength(0); i++)
                {
                    int y = 0;
                    int w = 0;

                    if (!loz)
                    {
                        for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                        {
                            if (this.Controls[radhaArray[i][j]].Text == "X")
                                y++;
                            else if (this.Controls[radhaArray[i][j]].Text == "O")
                                w++;
                        }
                        if (y == 2 && w == 0)
                        {
                            for (int z = 0; z < radhaArray[i].GetLength(0); z++)
                            {
                                if (this.Controls[radhaArray[i][z]].Text != "X")
                                {
                                    this.Controls[radhaArray[i][z]].Text = strLojtari;
                                    loz = true;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (!modi_lojes)
                {
                    if (this.Controls["b4"].Text == String.Empty)
                    {
                        this.Controls["b4"].Text = strLojtari;
                        loz = true;
                    }
                    else
                    {
                        for (int m = 0; m < radhaArray.GetLength(0); m++)
                        {
                            int y = 0;
                            int w = 0;

                            if (!loz)
                            {
                                for (int n = 0; n < radhaArray[m].GetLength(0); n++)
                                {
                                    if (this.Controls[radhaArray[m][n]].Text == "O")
                                        y++;
                                    else if (this.Controls[radhaArray[m][n]].Text == String.Empty)
                                        w++;
                                }

                                if (y == 1 && w == 2)
                                    kompjuteri_perparesi = true;
                            }
                        }

                        if(kompjuteri_perparesi)
                        {
                            for (int m = 0; m < radhaArray.GetLength(0); m++)
                            {
                                int y = 0;
                                int w = 0;

                                if (!loz)
                                {
                                    for (int n = 0; n < radhaArray[m].GetLength(0); n++)
                                    {
                                        if (this.Controls[radhaArray[m][n]].Text == "O")
                                            y++;
                                        else if (this.Controls[radhaArray[m][n]].Text == String.Empty)
                                            w++;
                                    }

                                    if (y == 1 && w == 2)
                                    {
                                        for (int z = 0; z < radhaArray[m].GetLength(0); z++)
                                        {
                                            if (!loz)
                                            {
                                                if (this.Controls[radhaArray[m][z]].Text != "O")
                                                {
                                                    this.Controls[radhaArray[m][z]].Text = strLojtari;
                                                    loz = true;
                                                }
                                            }
                                        }
                                    }
                                }            
                            }
                        }
                        else
                        {
                            for (int m = 0; m < radhaArray.GetLength(0); m++)
                            {
                                for (int n = 0; n < radhaArray[m].GetLength(0); n++)
                                {
                                    if (this.Controls[radhaArray[m][n]].Text == String.Empty)
                                    {
                                        vek_empty.Add(this.Controls[radhaArray[m][n]].Name.ToString());
                                    }
                                }
                            }

                            if (!loz)
                            {
                                if (vek_empty.Count > 0)
                                {
                                    int numri_random = rnd.Next(0, vek_empty.Count);
                                    this.Controls[vek_empty[numri_random].ToString()].Text = strLojtari;
                                    loz = true;
                                }
                            }
                        }

                    }
                }
                else
                {
                    for (int m = 0; m < radhaArray.GetLength(0); m++)
                    {
                        for (int n = 0; n < radhaArray[m].GetLength(0); n++)
                        {
                            if (this.Controls[radhaArray[m][n]].Text == String.Empty)
                            {
                                vek_empty.Add(this.Controls[radhaArray[m][n]].Name.ToString());
                            }
                        }
                    }
                    if (!loz)
                    {
                        if (vek_empty.Count > 0)
                        {
                            int numri_random = rnd.Next(0, vek_empty.Count);
                            this.Controls[vek_empty[numri_random].ToString()].Text = strLojtari;
                            loz = true;
                        }
                    }
                }
            }
        }

        private void kontrollo_rezultatin()
        {
            for (int i = 0; i < radhaArray.GetLength(0); i++)
            {
                int y = 0;
                for (int j = 0; j < radhaArray[i].GetLength(0); j++)
                {
                    if (this.Controls[radhaArray[i][j]].Text == strLojtari)
                        y++;
                    if (y == 3)
                    {
                        for (int z = 0; z < radhaArray[i].GetLength(0); z++)
                        {
                            if (this.Controls[radhaArray[i][z]].Text == "O")
                                this.Controls[radhaArray[i][z]].ForeColor = Color.Red;
                            else
                                this.Controls[radhaArray[i][z]].ForeColor = Color.Blue;
                        }

                        LojeRe.Focus();

                        if(modi_lojes)
                            lstRezLehte.Items.Add("Fitues " + radha_lojtarit);
                        else
                            lstRezVeshtire.Items.Add("Fitues " + radha_lojtarit);

                        loja_perfundoi = true;
                    }
                }
            }
        }

        private void LojeRe_Click(object sender, EventArgs e)
        {
            pastrimi_kimik();
            inicializo_lojen();
        }
        private void pastrimi_kimik()
        {
            List<Control> zhdukiButonat = new List<Control>(); 
            foreach (Control c in this.Controls) 
            {
                if (c is Button) 
                {
                    if (c.Name.Substring(0, 1) == "b")
                    {
                        zhdukiButonat.Add(c);
                    }
                } 
            }
            foreach (Control remove in zhdukiButonat)
            {
                this.Controls.Remove(remove);
                remove.Dispose();
            }
        }

        private void FshijRezultatin_Click(object sender, EventArgs e)
        {
            lstRezLehte.Items.Clear();
            lstRezVeshtire.Items.Clear();
        }

        private void rLehte_CheckedChanged(object sender, EventArgs e)
        {
            pastrimi_kimik();
            inicializo_lojen();
        }

        private void rVeshtire_CheckedChanged(object sender, EventArgs e)
        {
            pastrimi_kimik();
            inicializo_lojen();
        }
    }
} 



```

----------


## ViRuSi_ZeRo

hot prinz ideja jote nuk esht e keqe,por mesa pash un lojtari kishte shum munci per te fituar  (pothuajse gjithmon) por gjithsesi ideja me matric esht ide sh  mir... :buzeqeshje:   edhe grafika e uke topalli me pelqeu shum.. :buzeqeshje: .

----------


## ViRuSi_ZeRo

Nqs dikush nga ju ka ndonje loj apo program ne vb qe ka deshit ta diskutojm apo ta ndaj me ne ketu mund ta publikoni...

----------


## auLoN.

Une e kam instaluar kete program Visual Basic, por nuk po di si te krijoj edhe une nje kesi loje dhe me qfare prapashtese ta ruaj nese mund dikush te me tregoje ju kisha faliminderuar shume shume.

----------


## ViRuSi_ZeRo

Ne mund te te ndimojm te zgjidhim probleme qe ti has gjat nji programimi ,po nuk mund te mesojm dot qe nga fillimi programimin :i ngrysur:  po te bashkongjis disa foto qe te prezantohesh  me vb..

----------


## ViRuSi_ZeRo

ketu eshe shembull  faqa grafike e nje programi..

----------


## ViRuSi_ZeRo

ketu behet shkrimi i kodit

----------


## ViRuSi_ZeRo

ketu behet ekzekutimi

----------


## eni_

Ja dhe dicka e vogel qe shkruajta ne C. 
Fatkeqesisht nuk ka GUI si pjesa tjeter e postimeve.
Mund te luhet kunder kompjuterit  :buzeqeshje:  



```

/***************************************************************************
 * TRESH (tictactoe) programuar nga
 * Eni Bundo 
 * me date :26.3.09
 * 
 * Loja :
 * Personi qe ben 3 figura ne nje vije 
 * (vertikalisht, horizontalisht apo diagonalisht) fiton. 
 * 
 * Skema eshte e tille
 *
 * +---+---+---+
 * | 0 | 1 | 2 |
 * +---+---+---+
 * | 3 | 4 | 5 |
 * +---+---+---+
 * | 6 | 7 | 8 |
 * +---+---+---+
 * Ne fakt tabela eshte nje vektor (array) nje permasor.
 * Cdo numer kutie eshte indeksi i saj ne vektorin tone.
 * Psh. kutia me koordinatat X=1, Y=1 eshte vektori me indeks 0
 * Me sakt indeksi = (Y-1)*3 + X - 1 
 ****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define KOMPJUTERI 'X'
#define PERDORUESI 'O'

int leviz_random(void);
void deshironi_te_luani(void);
int eshte_bosh(int);
int kontrollo(int, int, int, char);
int rrezikon_per_tresh(void);
void afisho_tabelen(void);
int loja_ka_mbaruar(void);
void pyet_perdoruesin(void);
void kryej_levizjen_kompjuteri(void);
void fillo_lojen(void);
void rifillo(void);

int mundesite[8][3]={
    {0,1,2},
    {3,4,5},
    {6,7,8},
    {0,3,6},
    {1,4,7},
    {2,5,8},
    {0,4,8},
    {2,4,6}};

char tabela[]="---------";
int levizjet_totale=0;
int levizja_fundit_perdoruesit=-1; // inicializim

int leviz_random(void) { 
    int temp,
            counter=0,
            i;
    int levizjet_e_lejueshme[9];
    for (i=0; i<9; i++) { 
        if (tabela[i]=='-') {
            levizjet_e_lejueshme[counter]=i;
            counter++;
        } else 
            continue;
    }
    srand(time(NULL));
    temp = rand() % counter;
    return levizjet_e_lejueshme[temp];
}

void deshironi_te_luani(void) { 
    char zgjedhja[2];
    printf ("\nDeshironi te luani perseri:\nP/J\n");
    scanf("%s", zgjedhja);
    if (zgjedhja[0]=='P' || zgjedhja[0]=='p') 
        fillo_lojen();
    else
        exit(0);
}
int eshte_bosh(int c) {
    if (tabela[c]=='-') 
        return 1;
    else return 0;
}

int kontrollo(int a, int b, int c, char CFARE) {
    // -1 nese nuk rrezikon
    // 0..9 nese rrezikon ne nje kuti
    // 10 nese eshte bere tresh

    if (tabela[a] == tabela[b] && eshte_bosh(c) && tabela[a]==PERDORUESI)
        return c;
    else if (tabela[a] == tabela[c] && eshte_bosh(b) && tabela[a]==PERDORUESI)
        return b;
    else if (tabela[b] == tabela[c] && eshte_bosh(a) && tabela[b]==PERDORUESI)
        return a;
    else if (tabela[a]==tabela[b] && tabela[b]==tabela[c] && tabela[a]==CFARE) 
        return 10; // ka fituar CFARE
    else 
        return -1; // ska rrezik
}

int rrezikon_per_tresh(void) {
    int levizja, i;
    for (i=0; i<8; i++) {
        if ((levizja=kontrollo(mundesite[i][0], mundesite[i][1], mundesite[i][2], PERDORUESI)) != -1)
            return levizja;
        else
            continue;
    }
    return -1; // leviz random
}

void afisho_tabelen(void) { 
    int i;
    printf("\n\n");
    for (i=0; i<9; i++) { 
        printf ("%c", tabela[i]);
        if ((i==2) || (i==5)  || (i==8))
            printf ("\n");
        else
            continue;
    }
}

int loja_ka_mbaruar(void) {
    int i;
    for (i=0; i<8; i++) { 
        if (kontrollo(mundesite[i][0], mundesite[i][1], mundesite[i][2],PERDORUESI) == 10)  {
            printf ("perdoruesi fiton");
            return 1;
        } else if (kontrollo(mundesite[i][0], mundesite[i][1], mundesite[i][2],KOMPJUTERI) == 10) {
            printf ("kompjuteri fiton");
            return 1;
        } else
            continue;
    }
    if (levizjet_totale==9) {
        printf ("loja doli barazim");
        return 1;
    }
    return 0;
}

void pyet_perdoruesin(void) { 
    int x, y, a;
    printf ("x:");
    scanf("%d", &x);
    printf ("y:");
    scanf("%d", &y);
    if (eshte_bosh (a=(y-1)*3 + x - 1)) {
        tabela[a]=PERDORUESI;
        levizja_fundit_perdoruesit=a;
        levizjet_totale++;
        afisho_tabelen();
        if (loja_ka_mbaruar()) 
            deshironi_te_luani();
        else
            kryej_levizjen_kompjuteri();
    } else {
        printf ("\nkutia nuk eshte bosh\n");
        pyet_perdoruesin();
    }
}


void kryej_levizjen_kompjuteri(void) {
    int a,
            leviz_ketu;
    if ((levizja_fundit_perdoruesit == -1) || // sapo ka filluar loja
            ((a=rrezikon_per_tresh()) == -1)) { // nuk rrezikon
        leviz_ketu=leviz_random();

        while(!eshte_bosh(leviz_ketu)) {
            leviz_ketu=leviz_random();
        }
    }
    else 
        leviz_ketu = a;
    tabela[leviz_ketu] = KOMPJUTERI;
    levizjet_totale++;
    afisho_tabelen();
    if (loja_ka_mbaruar()) 
        deshironi_te_luani();
    else
        pyet_perdoruesin();
}

void rifillo() { 
    int i;
    for (i=0; i<9; i++) {
        tabela[i]='-';
    }
    levizja_fundit_perdoruesit=-1;
    levizjet_totale=0;
}

void fillo_lojen(void) {
    rifillo();
    afisho_tabelen();
    int kush_leviz;
    srand(time(NULL));
    kush_leviz = rand() % 2;
    if (kush_leviz) kryej_levizjen_kompjuteri();
    else pyet_perdoruesin();
}

int main () { 
    fillo_lojen();
    return 0;
} 



```

----------

