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

📄 frmclient.frm

📁 这是VB6.0上MSDN的例子
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmclient 
   Caption         =   "TCP客户端"
   ClientHeight    =   5160
   ClientLeft      =   9885
   ClientTop       =   6090
   ClientWidth     =   5235
   LinkTopic       =   "Form1"
   ScaleHeight     =   5160
   ScaleWidth      =   5235
   Begin VB.TextBox txthostname 
      Height          =   375
      Left            =   840
      TabIndex        =   5
      Top             =   3960
      Width           =   3255
   End
   Begin VB.CommandButton cmdconnect 
      Caption         =   "连接"
      Height          =   375
      Left            =   3120
      TabIndex        =   4
      Top             =   4440
      Width           =   975
   End
   Begin MSWinsockLib.Winsock wskclient 
      Left            =   0
      Top             =   360
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
      LocalPort       =   10001
   End
   Begin VB.TextBox txtoutput 
      Height          =   1095
      Left            =   840
      MultiLine       =   -1  'True
      TabIndex        =   1
      Top             =   2160
      Width           =   3255
   End
   Begin VB.TextBox txtsend 
      Height          =   1095
      Left            =   840
      MultiLine       =   -1  'True
      TabIndex        =   0
      Top             =   480
      Width           =   3255
   End
   Begin VB.Label labIPadd 
      Caption         =   "请输入IP地址"
      Height          =   255
      Left            =   840
      TabIndex        =   6
      Top             =   3720
      Width           =   1695
   End
   Begin VB.Label laboutput 
      Caption         =   "输出数据"
      Height          =   255
      Left            =   840
      TabIndex        =   3
      Top             =   1920
      Width           =   1455
   End
   Begin VB.Label labsend 
      Caption         =   "发送数据"
      Height          =   255
      Left            =   840
      TabIndex        =   2
      Top             =   240
      Width           =   1575
   End
End
Attribute VB_Name = "frmclient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_Load()

    Load frmserver

   'Winsock 控件的名字为 wskclient。
   '注意:要指定远程主机,可以使用IP 地址(例如:"121.111.1.1"),也可以使用计算机的“好听的名字”如下所示。
   
   
End Sub

Private Sub cmdconnect_Click()
    
    
    wskclient.RemoteHost = txthostname.Text
    wskclient.RemotePort = 1000
   
    '调用 Connect 方法,初始化连接。
    wskclient.Connect
    cmdconnect.Enabled = False
    
End Sub


Private Sub txtsend_Change()
    
    wskclient.SendData txtsend.Text
    
End Sub

Private Sub wskclient_DataArrival(ByVal bytesTotal As Long)

   Dim strData As String
   wskclient.GetData strData
   frmclient.txtoutput.Text = strData
   
End Sub


⌨️ 快捷键说明

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