wuziclient.frm
来自「vb编程+从基础到实践光盘代码」· FRM 代码 · 共 2,139 行 · 第 1/5 页
FRM
2,139 行
'X = (X - Me.Width) / 2
'Y = (Y - Me.Height) / 2
'Me.Move X, Y
'MyColor = 1
'OtherColor = 2
Drawing = False
'TimeDisplayB.Text = Format(Time, "hh:mm:ss")
For l = 1 To 14
For j = 1 To 14
DataArray(i, j) = 5
Next j
Next l
TalkWay.AddItem "shout", 0
TalkWay.AddItem "tell", 1
TalkWay.AddItem "chat", 2
TalkWay.ListIndex = 0
ColorChoose.ListIndex = 0
'TCP2.RemoteHost = "caojw"
TCP2.RemoteHost = "localhost"
TCP2.RemotePort = 2002
End Sub
Private Sub Form_Resize()
'PicQipan.Move ScaleLeft, ScaleTop, ScaleWidth * 0.5, ScaleHeight
For i = 1 To 14
PicQipan.Line (SubWidth, SubWidth * i)-(SubWidth * 14, _
SubWidth * i)
PicQipan.Line (SubWidth * i, SubWidth)-(SubWidth * i, _
SubWidth * 14)
Next i
End Sub
Private Sub HScroll1_Change()
Frame3.Left = -HScroll1.Value * 29
End Sub
Private Sub login_Click()
If Nickname.Text = "" Then
note = MsgBox("请输入昵称", vbCritical, "注意")
Nickname.SetFocus
Exit Sub
End If
If Password.Text = "" Then
note = MsgBox("请输入密码", vbCritical, "注意")
Password.SetFocus
Exit Sub
End If
If Email.Text = "" Then
note = MsgBox("请输入电子邮件", vbCritical, "注意")
Email.SetFocus
Exit Sub
End If
YourNickName = Nickname.Text
Sendmessage.Enabled = True
Users.Enabled = True
Frame1.Visible = False
On Error GoTo err1:
TCP2.SendData "/1:" & Nickname.Text & ":" & Password.Text & _
":" & Email.Text
Exit Sub
err1:
MsgBox ("注册不成功!")
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub MessageBox_GotFocus()
MessageSend.SetFocus
End Sub
Private Sub PicQipan_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim x0 As Integer
Dim y0 As Integer
Dim X1 As Single
Dim Y1 As Single
If Not Drawing Then
Exit Sub
End If
If LocalPlay Then
Call LocalFunction(X, Y)
Exit Sub
End If
If X < 10 Or X > 14.5 * SubWidth Or Y < SubWidth Or Y > 14.5 * SubWidth Then
MsgBox "超出棋盘界限,请重新下"
Exit Sub
End If
If Abs(Int(X / SubWidth) - X / SubWidth) < 0.5 Then
x0 = Int(X / SubWidth)
Else
x0 = Int(X / SubWidth) + 1
End If
If Abs(Int(Y / SubWidth) - Y / SubWidth) < 0.5 Then
y0 = Int(Y / SubWidth)
Else
y0 = Int(Y / SubWidth) + 1
End If
'X = X + SubWidth / 2
'Y = Y + SubWidth / 2
'X0 = X / SubWidth
'Y0 = Y / SubWidth
If DataArray(x0, y0) <> 5 Then
'当前位置已经有棋子了,
MsgBox "当前位置已经有棋子了,请重新走!", vbCritical, "NOTE!"
Exit Sub
End If
DataArray(x0, y0) = MyColor
Buffer = Buffer & Format(x0, "00") & "-" & Format(y0, "00") & ":"
For i = 1 To 14
For j = 1 To 14
If DataArray(i, j) = MyColor And Not IfSucceed Then
If (14 - i) >= 4 And (14 - j) >= 4 Then
If DataArray(i + 1, j + 1) = MyColor Then
If DataArray(i + 2, j + 2) = MyColor Then
If DataArray(i + 3, j + 3) = MyColor Then
If DataArray(i + 4, j + 4) = MyColor Then
IfSucceed = True
Exit For
Exit For
End If
End If
End If
End If
End If
If i > 4 And (14 - j) >= 4 Then
If DataArray(i - 1, j + 1) = MyColor Then
If DataArray(i - 2, j + 2) = MyColor Then
If DataArray(i - 3, j + 3) = MyColor Then
If DataArray(i - 4, j + 4) = MyColor Then
IfSucceed = True
Exit For
Exit For
End If
End If
End If
End If
End If
'IfSucceed = IfSucceed + 1
If (14 - i) >= 4 Then
If DataArray(i + 1, j) = MyColor Then
'IfSucceed = IfSucceed + 1
If DataArray(i + 2, j) = MyColor Then
If DataArray(i + 3, j) = MyColor Then
If DataArray(i + 4, j) = MyColor Then
IfSucceed = True
Exit For
Exit For
End If
End If
End If
End If
End If
If (14 - j) >= 4 Then
If DataArray(i, j + 1) = MyColor Then
If DataArray(i, j + 2) = MyColor Then
If DataArray(i, j + 3) = MyColor Then
If DataArray(i, j + 4) = MyColor Then
IfSucceed = True
Exit For
Exit For
End If
End If
End If
End If
End If
End If
Next j
Next i
If IfSucceed Then
If MyColor = 0 Then
PicQipan.FillColor = vbBlack
PicQipan.ForeColor = vbBlack
Else
PicQipan.FillColor = vbWhite
PicQipan.ForeColor = vbWhite
End If
'PicQipan.DrawMode
PicQipan.FillStyle = 0
PicQipan.Circle (x0 * SubWidth, y0 * SubWidth), SubWidth / 3
TCP2.SendData "/W:"
Drawing = False
TimeBlack.Enabled = False
TimeWhite.Enabled = False
IfPlaying = False
Exit Sub
End If
If MyColor = 0 Then
PicQipan.FillColor = vbBlack
PicQipan.ForeColor = vbBlack
WhiteName.Caption = "对方走..."
BlackName.Caption = YourNickName
Else
PicQipan.FillColor = vbWhite
PicQipan.ForeColor = vbWhite
WhiteName.Caption = YourNickName
BlackName.Caption = "对方走..."
End If
'PicQipan.DrawStyle = 6
PicQipan.FillStyle = 0
'PicQipan.DrawMode
PicQipan.Circle (x0 * SubWidth, y0 * SubWidth), SubWidth / 3
'Call DrawPill(X0, Y0)
Drawing = False
If MyColor = 0 Then
TimeBlack.Enabled = False
TimeWhite.Enabled = True
Mytime = Format(Time, "hh:mm:ss")
If TimeDisplayW.Text <> "" Then
MidVariant = CDate(TimeDisplayW.Text)
End If
Else
TimeWhite.Enabled = False
TimeBlack.Enabled = True
Mytime = Format(Time, "hh:mm:ss")
If TimeDisplayB.Text <> "" Then
MidVariant = CDate(TimeDisplayB.Text)
End If
End If
If MyColor = 0 Then
TCP2.SendData "/D:" & Str(x0) & ":" & Str(y0) & ":" & _
TimeDisplayB.Text
Else
TCP2.SendData "/D:" & Str(x0) & ":" & Str(y0) & ":" & _
TimeDisplayW.Text
End If
StatusBar1.SimpleText = "请稍后,对方正在考虑......"
End Sub
Private Sub Register_Click()
If Register.Tag = 1 Then
Frame1.Visible = True
' Register.Enabled = False
Frame2.Visible = False
Frame5.Visible = False
Frame6.Visible = False
' Register.Tag = 2
' Register.Enabled = True
' Users.Enabled = True
'Else
' Register.Enabled = True
' Register.Tag = 1
' TCP2.Close
' Register.Enabled = False
' Users.Enabled = False
' Sendmessage.Enabled = False
End If
End Sub
Private Sub Sendmessage_Click()
Frame2.Visible = True
Frame1.Visible = False
Frame5.Visible = False
Frame6.Visible = False
End Sub
Private Sub TalkWay_Click()
If TalkWay.ListIndex = 1 Then
UserChoose.Visible = True
Label5.Visible = True
Else
Label5.Visible = False
UserChoose.Visible = False
End If
End Sub
Private Sub TCP2_DataArrival(ByVal bytesTotal As Long)
Dim Information As String
Dim DivideInfo As String
'Dim UserNum As Integer
Dim TimeBCount As String
TCP2.GetData Information
If Left(Information, 1) = "/" Then
Select Case Mid$(Information, 2, 1)
Case 0
MessageBox.Text = MessageBox.Text & "你已经连接到服务器了,请首先注册!" & _
vbCrLf
Timer1.Enabled = False
TimeCount = 0
Connect.Caption = "下网"
Register.Enabled = True
PlayingNum = CInt(Mid$(Information, 4))
MsgBox "你已经连接到服务器了!!"
Case 1
MessageBox.Text = MessageBox.Text & _
"你已经成功登陆到wxp的五子棋俱乐部,希望你们" & _
"遵守各项规章制度,提高自己的五子棋水平!" & vbCrLf
MsgBox "你是第" & Mid$(Information, 4) & "个登陆到本系统的用户", vbOKOnly, "注册成功"
Register.Enabled = False
Sendmessage.Enabled = True
Users.Enabled = True
cmdPlay.Enabled = True
Watch.Enabled = True
Connected = True
WuziClient.Caption = WuziClient.Caption & "--" & YourNickName & "登陆"
Case 2
' MessageBox.Text = MessageBox.Text + Mid$(Information, 4)
For i = 1 To MaxConnect
Use(i) = False
Next
DivideInfo = Mid$(Information, 4)
temp1 = 1
temp2 = InStr(1, DivideInfo, "|", vbTextCompare)
'将原来的对象清除,然后更新
UserChoose.Clear
'将原来的对象清除,然后更新
Opponent.Clear
If temp2 = 0 Then
MessageBox.Text = MessageBox.Text & "目前没有用户!" & vbCrLf
Else
Do While temp2 <> 0
tempstr1 = Mid$(DivideInfo, temp1, temp2 - temp1)
AllUserss(CInt(Right(tempstr1, 3))).Nickname = _
Left(tempstr1, Len(tempstr1) - 3)
AllUserss(CInt(Right(tempstr1, 3))).IndexNum = _
CInt(Right(tempstr1, 3))
UserChoose.AddItem Left(tempstr1, Len(tempstr1) - 3)
Opponent.AddItem Left(tempstr1, Len(tempstr1) - 3)
MessageBox.Text = MessageBox.Text & _
AllUserss(CInt(Right(tempstr1, 3))).Nickname & vbCrLf
UserNum = UserNum + 1
Use(CInt(Right(tempstr1, 3))) = True
temp1 = temp2 + 1
temp2 = InStr(temp2 + 1, DivideInfo, "|", vbTextCompare)
Loop
End If
' For i = 1 To MaxConnect
' If AllUserss(i).Index <> "" Then
'显示shout的内容
Case 3
MessageBox.Text = MessageBox.Text & Mid$(Information, 4) & _
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?