Dim Valore As String Private Sub Form_Load Valore FinePartita False En

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Dim Valore As String
Private Sub Form_Load()
Valore = "O"
'FinePartita (False)
End Sub
Private Sub Command2_Click()
wskTris.SendData ("new_game")
Dim i As Integer
i = 0
For i = 0 To 8
Command1(i).Enabled = True
Command1(i).Caption = ""
Next i
End Sub
Private Sub FinePartita(state As Boolean)
Dim i As Integer
i = 0
If state = False Then
For i = 0 To 8
Command1(i).Enabled = False
Next i
Else
For i = 0 To 8
Command1(i).Enabled = True
Next i
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command1_Click(Index As Integer)
If Valore = "O" Then
Command1(Index).Caption = "O"
Else
Command1(Index).Caption = "X"
End If
wskTris.SendData ("bla bla")
Command1(Index).Enabled = False
FinePartita (False)
If Command1(0).Caption <> "" And Command1(0).Caption = Command1(3).Caption And Command1(0).Caption = Command1(6).Caption Then
MsgBox Command1(0).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
If Command1(1).Caption <> "" And Command1(1).Caption = Command1(4).Caption And Command1(1).Caption = Command1(7).Caption Then
MsgBox Command1(1).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
If Command1(2).Caption <> "" And Command1(2).Caption = Command1(5).Caption And Command1(2).Caption = Command1(8).Caption Then
MsgBox Command1(2).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
If Command1(0).Caption <> "" And Command1(0).Caption = Command1(1).Caption And Command1(0).Caption = Command1(2).Caption Then
MsgBox Command1(0).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
If Command1(3).Caption <> "" And Command1(0).Caption = Command1(4).Caption And Command1(3).Caption = Command1(5).Caption Then
MsgBox Command1(3).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
If Command1(6).Caption <> "" And Command1(6).Caption = Command1(7).Caption And Command1(6).Caption = Command1(8).Caption Then
MsgBox Command1(6).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
If Command1(0).Caption <> "" And Command1(0).Caption = Command1(4).Caption And Command1(0).Caption = Command1(8).Caption Then
MsgBox Command1(0).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
If Command1(2).Caption <> "" And Command1(2).Caption = Command1(4).Caption And Command1(2).Caption = Command1(6).Caption Then
MsgBox Command1(2).Caption & " Ha Vinto"
FinePartita (False)
Exit Sub
End If
End Sub
Private Sub wskTris_ConnectionRequest(ByVal requestID As Long) 'funzione che gestisce la conessione
wskTris.Close
wskTris.Accept requestID
MsgBox "Conessione avvenuta"
End Sub
Private Sub cmdConnect_Click()
wskTris.Connect txtHost.Text, txtPort.Text 'richiesta di conessione
End Sub
Private Sub Option1_Click()
wskTris.LocalPort = 4000
wskTris.Listen
Valore = "X" 'server gioca con X
cmdConnect.Enabled = False
End Sub
Private Sub wskTris_DataArrival(ByVal bytesTotal As Long)
Dim DataRecieved As String
Dim Index As Double
wskTris.GetData DataRecivied, vbString, bytesTotal
Text1.Text = DataRecieved
FinePartita (True)
End Sub