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

📄 frmclient.frm

📁 1.打开文件。在服务器计算机上运行服务器可执行程序
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmClient 
   Caption         =   "client"
   ClientHeight    =   5460
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5130
   LinkTopic       =   "Form1"
   ScaleHeight     =   5460
   ScaleWidth      =   5130
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox txtreceive 
      Height          =   3615
      Left            =   360
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   5
      Top             =   480
      Width           =   4335
   End
   Begin VB.CommandButton clear 
      Caption         =   "清空"
      Height          =   375
      Left            =   2640
      TabIndex        =   4
      Top             =   4920
      Width           =   735
   End
   Begin VB.TextBox ipadr 
      Height          =   375
      Left            =   1680
      TabIndex        =   3
      Top             =   120
      Width           =   1935
   End
   Begin VB.CommandButton cmdsent 
      Caption         =   "发送"
      Height          =   375
      Left            =   3960
      TabIndex        =   2
      Top             =   4920
      Width           =   735
   End
   Begin VB.CommandButton cmdconnect 
      Caption         =   "连接"
      Height          =   375
      Left            =   3960
      TabIndex        =   1
      Top             =   120
      Width           =   735
   End
   Begin VB.TextBox txtsend 
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   4440
      Width           =   4335
   End
   Begin MSWinsockLib.Winsock sckclient 
      Left            =   4680
      Top             =   840
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.Label Label1 
      Caption         =   "请输入IP或主机名:"
      Height          =   255
      Left            =   0
      TabIndex        =   8
      Top             =   120
      Width           =   1695
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "Label4"
      Height          =   255
      Left            =   1320
      TabIndex        =   7
      Top             =   5040
      Width           =   3255
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "你的IP地址:"
      Height          =   255
      Left            =   360
      TabIndex        =   6
      Top             =   5040
      Width           =   975
   End
End
Attribute VB_Name = "frmClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub clear_Click()
txtreceive.Text = ""
End Sub

Private Sub cmdConnect_Click()
     On Error GoTo ErrorPro
     sckclient.Connect
     Exit Sub
ErrorPro:
    MsgBox "服务器未开或网络出错,请重新连接!"
    End
End Sub

Private Sub cmdSent_Click()
    Dim s  As String
    s = xingming + "说:" + txtsend.Text
    sckclient.SendData s
    txtreceive.Text = txtreceive.Text + Chr$(13) + Chr$(10) + "我说:" + txtsend.Text
    txtsend.Text = ""
End Sub

Private Sub Form_Load()
    sckclient.RemoteHost = ipadr
    sckclient.RemotePort = 1011
    txtreceive.Text = "welcome---" + xingming + "!!!"
    Label4.Caption = sckclient.LocalIP
End Sub

Private Sub ipadr_Change()
sckclient.RemoteHost = ipadr.Text
End Sub

Private Sub ipadr_Click()
ipadr.Text = ""
End Sub

Private Sub sckClient_Close()
    If sckclient.State <> closed Then
      sckclient.Close
      cmdconnect.Enabled = False
      MsgBox "未建立连接,请重试!"
    End If
End Sub
    
Private Sub sckClient_Connect()
   MsgBox "已成功建立连接!"
    cmdconnect.Enabled = False
End Sub

Private Sub sckClient_DataArrival(ByVal bytesTotal As Long)
    Dim s As String
    sckclient.GetData s
    If Left(Trim(s), num) <> xingming Then
      txtreceive.Text = txtreceive.Text + Chr$(13) + Chr$(10) + s
    End If
End Sub

Private Sub sckClient_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
      sckclient.Close
      cmdconnect.Enabled = True
End Sub




Private Sub txtsend_KeyPress(KeyAscii As Integer)
    Dim s  As String
    If KeyAscii = 13 Then
     s = xingming + "说:" + txtsend.Text
     sckclient.SendData s
     txtreceive.Text = txtreceive.Text + Chr$(13) + Chr$(10) + "我说:" + txtsend.Text
     txtsend.Text = ""
    End If
End Sub

⌨️ 快捷键说明

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