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

📄 form2.frm

📁 双合棋,这个游戏是本人用一周多的时间编写的。已基本成形
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   AutoRedraw      =   -1  'True
   BorderStyle     =   0  'None
   ClientHeight    =   3735
   ClientLeft      =   5310
   ClientTop       =   3120
   ClientWidth     =   6015
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Picture         =   "Form2.frx":0000
   ScaleHeight     =   3735
   ScaleWidth      =   6015
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton Command2 
      BackColor       =   &H00609FD5&
      Caption         =   "退出"
      Height          =   315
      Left            =   4590
      TabIndex        =   8
      Top             =   3330
      Width           =   1275
   End
   Begin VB.CommandButton Command1 
      Caption         =   " 连接"
      Height          =   315
      Left            =   3300
      TabIndex        =   7
      Top             =   3330
      Width           =   1185
   End
   Begin VB.TextBox Text2 
      BackColor       =   &H009FD2FF&
      ForeColor       =   &H00C00000&
      Height          =   315
      Left            =   30
      TabIndex        =   6
      Text            =   "Text2"
      Top             =   3330
      Width           =   3075
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00609FD5&
      Caption         =   "角色选择"
      ForeColor       =   &H00003767&
      Height          =   1095
      Left            =   30
      TabIndex        =   2
      Top             =   2010
      Width           =   3135
      Begin VB.OptionButton Option2 
         BackColor       =   &H00609FD5&
         Caption         =   "客户端"
         ForeColor       =   &H00003767&
         Height          =   255
         Left            =   360
         TabIndex        =   4
         Top             =   600
         Width           =   975
      End
      Begin VB.OptionButton Option1 
         BackColor       =   &H00609FD5&
         Caption         =   "服务器端"
         ForeColor       =   &H00003767&
         Height          =   255
         Left            =   360
         TabIndex        =   3
         Top             =   240
         Width           =   1095
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "注意!>>"
         ForeColor       =   &H00003767&
         Height          =   180
         Left            =   2400
         TabIndex        =   9
         Top             =   900
         Width           =   720
      End
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H009FD2FF&
      ForeColor       =   &H00C00000&
      Height          =   375
      Left            =   3300
      TabIndex        =   1
      Text            =   "我懒,不要名字"
      Top             =   2730
      Width           =   2535
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "IP地址"
      ForeColor       =   &H00003767&
      Height          =   180
      Left            =   30
      TabIndex        =   5
      Top             =   3120
      Width           =   540
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "玩家姓名"
      ForeColor       =   &H00003767&
      Height          =   180
      Left            =   3300
      TabIndex        =   0
      Top             =   2430
      Width           =   720
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit




Dim CX2 As Integer, CY2 As Integer
Dim DragW2 As Boolean

Private Sub Command1_Click()

Dim i As Integer
If Server = 1 Then
    Form1.Winsock1.LocalPort = PORT '设置端口
    Form1.Winsock1.Listen '建立监听
    Form1.lblBlackName.Caption = "己方:" + Text1.Text '赋值玩家姓名
    Form1.lblInfo.Caption = "等待加入。。。。。。"
    
    
    Form1.lblBlackScore.Caption = "战绩: " + Str(win(1)) + "胜 " + Str(win(1)) + "败"
    Form1.lblWhiteScore.Caption = "战绩: " + Str(win(2)) + "胜 " + Str(win(2)) + "败"
    Form1.Show
    Form2.Hide
    Unload Form2
    Reset '清空棋盘
    
ElseIf Server = 2 Then
    Form1.Winsock1.RemoteHost = Text2.Text '设置服务器IP
    Form1.Winsock1.RemotePort = PORT '设置端口
    Form1.Winsock1.LocalPort = 0 '设置本地端口
    Form1.Winsock1.Connect
    Form1.lblWhiteName.Caption = "己方:" + Text1.Text '赋值玩家姓名"
    Form1.lblInfo.Caption = "正在连接服务器" + Text2.Text + "。。。。。。" ' 显示信息
      
    Form1.lblBlackScore.Caption = "战绩: " + Str(win(1)) + "胜 " + Str(win(1)) + "败"
    Form1.lblWhiteScore.Caption = "战绩: " + Str(win(2)) + "胜 " + Str(win(2)) + "败"
    Form1.Show
    
    Form2.Hide
    Reset '清空棋盘
    
    Else: MsgBox "请选择服务器或客户端!"
End If
    
End Sub

Private Sub Command2_Click()
End
End Sub
'拖动

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DragW2 = True
Form2.MousePointer = 5
CX2 = X
CY2 = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If DragW2 = True Then
Form2.Left = (Form2.Left + (X)) - CX2
Form2.Top = (Form2.Top + (Y)) - CY2
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
DragW2 = False
Form2.MousePointer = 1
End Sub
Private Sub Form_Load()
MaxNum(2) = 37 '设成不可能达到的数
MaxNum(3) = 37
MaxNum(4) = 3
MaxNum(5) = 4
MaxNum(6) = 5
MaxNum(7) = 6
MaxNum(8) = 5
MaxNum(9) = 4
MaxNum(10) = 3
MaxNum(11) = 37
MaxNum(12) = 37
If Len(Dir$("C:\WINDOWS\system32\MSWINSCK.OCX")) <= 1 Then
    FileCopy App.Path + "\MSWINSCK.OCX", "C:\WINDOWS\system32\MSWINSCK.OCX"
End If
Dim ret As Long, hKey As Long
ret = RegOpenKey(HKEY_CLASSES_ROOT, "Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d", hKey)
If ret <> 0 Then
regvb6
End If

End Sub

Private Sub Label3_Click()
MsgBox "注意:服务器端先连接后,客户端再连接!"
End Sub

Private Sub Option1_Click()
Text2.Text = Form1.Winsock1.LocalIP '显示本机IP
Server = 1 '作为服务器
Label2.Caption = "本机IP为:"
End Sub

Private Sub Option2_Click()
Text2.Text = "127.0.0.1" '显示本机IP
Server = 2 '作为客户端
Label2.Caption = "请输入服务器端IP。"
End Sub


⌨️ 快捷键说明

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