⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net5-1.frm

📁 网络五子棋,有关网络编程方面很好的实例,值得一看
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1 
   BackColor       =   &H00000000&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "网络五子棋 v0.22"
   ClientHeight    =   6795
   ClientLeft      =   150
   ClientTop       =   150
   ClientWidth     =   9450
   ClipControls    =   0   'False
   Icon            =   "net5-1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   6795
   ScaleWidth      =   9450
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Com1 
      Caption         =   "断线结束"
      Height          =   375
      Index           =   4
      Left            =   8280
      TabIndex        =   11
      Top             =   6240
      Width           =   975
   End
   Begin VB.CommandButton Com1 
      Caption         =   "重新连线"
      Height          =   375
      Index           =   3
      Left            =   7200
      TabIndex        =   10
      Top             =   6240
      Width           =   975
   End
   Begin VB.CommandButton Com1 
      Caption         =   "开新棋局"
      Height          =   375
      Index           =   2
      Left            =   6120
      TabIndex        =   9
      Top             =   6240
      Width           =   975
   End
   Begin VB.CommandButton Com1 
      Caption         =   "清除"
      Height          =   375
      Index           =   1
      Left            =   5280
      TabIndex        =   8
      Top             =   6240
      Width           =   735
   End
   Begin VB.CommandButton Com1 
      Caption         =   "送出"
      Height          =   375
      Index           =   0
      Left            =   4440
      TabIndex        =   3
      Top             =   6240
      Width           =   735
   End
   Begin VB.ComboBox Combo1 
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   360
      ItemData        =   "net5-1.frx":030A
      Left            =   120
      List            =   "net5-1.frx":030C
      TabIndex        =   2
      Top             =   6240
      Width           =   4215
   End
   Begin VB.PictureBox Pic1 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   4575
      Left            =   600
      Picture         =   "net5-1.frx":030E
      ScaleHeight     =   303
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   319
      TabIndex        =   0
      Top             =   480
      Width           =   4815
   End
   Begin MSWinsockLib.Winsock Winsock1 
      Left            =   0
      Top             =   0
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.PictureBox Pic2 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   330
      Left            =   960
      Picture         =   "net5-1.frx":C0F0
      ScaleHeight     =   20
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   84
      TabIndex        =   13
      Top             =   720
      Width           =   1290
   End
   Begin VB.Label Label3 
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   120
      TabIndex        =   14
      Top             =   5520
      Width           =   5895
   End
   Begin VB.Image Image2 
      Height          =   2100
      Left            =   6000
      Picture         =   "net5-1.frx":CBC2
      Top             =   120
      Width           =   2910
   End
   Begin VB.Image Image1 
      Height          =   2100
      Index           =   1
      Left            =   6360
      Picture         =   "net5-1.frx":F236
      Top             =   3720
      Visible         =   0   'False
      Width           =   2340
   End
   Begin VB.Image Image1 
      Height          =   2100
      Index           =   0
      Left            =   6360
      Picture         =   "net5-1.frx":10D7C
      Top             =   3720
      Visible         =   0   'False
      Width           =   2340
   End
   Begin VB.Label Label2 
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   6120
      TabIndex        =   12
      Top             =   5880
      Width           =   3135
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Index           =   4
      Left            =   6000
      TabIndex        =   7
      Top             =   3480
      Width           =   3015
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Index           =   3
      Left            =   6000
      TabIndex        =   6
      Top             =   3120
      Width           =   3015
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Index           =   2
      Left            =   6000
      TabIndex        =   5
      Top             =   2640
      Width           =   3015
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Index           =   1
      Left            =   6000
      TabIndex        =   4
      Top             =   2280
      Width           =   3015
   End
   Begin VB.Label Label1 
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "MS Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   1
      Top             =   5880
      Width           =   5895
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Com1_Click(Index As Integer)
Select Case Index
   Case 0
     Label3.Caption = Combo1.Text
     Send "5" + Combo1.Text
   Case 1
     Combo1.Text = ""
   Case 2
     Send "3"
     ResetGame
     If Server = 1 Then Pic1.Enabled = True Else Pic1.Enabled = False
   Case 3
     If Label2.Caption = "连线中" Then
        Send "4"
        DoEvents
     End If
     Winsock1.Close
     Label2.Caption = "尚未连线"
     Load Form2
     Form2.Show
   Case 4
     If Label2.Caption = "连线中" Then
        Send "4"
        DoEvents
     End If
     Winsock1.Close
     End
End Select
End Sub

Private Sub Form_Load()
Open "net5.txt" For Input As #1
Do
  Input #1, Gdata
  Combo1.AddItem Gdata
  If EOF(1) Then Close #1: Exit Sub
Loop
End Sub

Private Sub Form_Unload(Cancel As Integer)
     If Label2.Caption = "连线中" Then
        Send "4"
        DoEvents
     End If
     Winsock1.Close
     End
End Sub

Private Sub Pic1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
sx = Fix(X / 21) + 1: sy = Fix(Y / 20) + 1
If map(sx, sy) <> 0 Then Exit Sub
Call sndPlaySound("put.wav", 0)
map(sx, sy) = Server
DrawScreen
a = GameOver(Server)
If a = Server Then
   Image1(0).Visible = True
   Win(Server) = Win(Server) + 1
   If Server = 1 Then Lost(2) = Lost(2) + 1 Else Lost(1) = Lost(1) + 1
   Form1.Label1(2).Caption = "战绩:" + Str(Win(1)) + "胜" + Str(Lost(1)) + "败"
   Form1.Label1(4).Caption = "战绩:" + Str(Win(2)) + "胜" + Str(Lost(2)) + "败"
End If
Send "1" + Chr(sx) + Chr(sy)
Pic1.Enabled = False
End If
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
Label2.Caption = "连线中"
OpenCom
Pic1.Enabled = True
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
GetMyData bytesTotal
End Sub

Private Sub Winsock1_Connect()
Label2.Caption = "连线中"
Send "2" + Label1(3).Caption
OpenCom
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -