Dim x As Integer
Option Explicit
Private Sub cmdConnect_Click()
With udpPeerA
.RemoteHost = txtHostName.Text
If chkMain.Value Then
.RemotePort = 1001 '連線的連接埠號。
.Bind 1002 '連結到本機的連接埠。
Else
.RemotePort = 1002
.Bind 1001
End If
End With
End Sub
Private Sub cmdSend_Click()
txtSend.Text = x
udpPeerA.SendData txtSend.Text
Select Case x
Case 1
If txtOutput.Text = 1 Then
Text1.Text = "平手"
ElseIf txtOutput.Text = 2 Then
Text1.Text = "你輸了"
ElseIf txtOutput.Text = 3 Then
Text1.Text = "你贏了"
End If
Case 2
If txtOutput.Text = 2 Then
Text1.Text = "平手"
ElseIf txtOutput.Text = 3 Then
Text1.Text = "你輸了"
ElseIf txtOutput.Text = 1 Then
Text1.Text = "你贏了"
End If
Case 3
If txtOutput.Text = 3 Then
Text1.Text = "平手"
ElseIf txtOutput.Text = 1 Then
Text1.Text = "你輸了"
ElseIf txtOutput.Text = 2 Then
Text1.Text = "你贏了"
End If
End Select
DoEvents
End Sub
Private Sub Command1_Click()
Randomize Timer
x = Int(Rnd() * 3 + 1)
End Sub
Private Sub udpPeerA_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
udpPeerA.GetData strData
txtOutput.Text = strData
End Sub
沒有留言:
張貼留言