socketsrv.frm

来自「VB源码,是初学者的福因.让你很快掌握VB编程」· FRM 代码 · 共 84 行

FRM
84
字号
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "mswinsck.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3885
   LinkTopic       =   "Form1"
   ScaleHeight     =   3000
   ScaleMode       =   0  'User
   ScaleWidth      =   4000
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox TextGet 
      Enabled         =   0   'False
      Height          =   495
      Left            =   240
      TabIndex        =   2
      Text            =   "接收的文本"
      Top             =   2040
      Width           =   3495
   End
   Begin MSWinsockLib.Winsock WinsockServer 
      Left            =   2880
      Top             =   120
      _ExtentX        =   741
      _ExtentY        =   741
   End
   Begin VB.TextBox TextSend 
      Height          =   495
      Left            =   240
      TabIndex        =   1
      Text            =   "发送的文本"
      Top             =   1320
      Width           =   3495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "退出服务器"
      Height          =   495
      Left            =   840
      TabIndex        =   0
      Top             =   120
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
  Private Sub Command1_Click()
     WinsockServer.Close
     End
  End Sub
   
  Private Sub Form_Load()
     TextSend.Visible = False
     TextGet.Visible = False
     WinsockServer.LocalPort = 12315
     WinsockServer.Listen
  End Sub
   
  Private Sub TextSend_Change()
    WinsockServer.SendData TextSend.Text
  End Sub
   
  Private Sub WinsockServer_Close()
    WinsockServer.Close
    Form_Load
  End Sub
   
  Private Sub Winsockserver_ConnectionRequest(ByVal requestID As Long)
    TextSend.Visible = True
    TextGet.Visible = True
    If WinsockServer.State <> sckClosed Then WinsockServer.Close
    WinsockServer.Accept requestID
  End Sub
   
  Private Sub Winsockserver_DataArrival(ByVal bytesTotal As Long)
    Dim tmpstr As String
    WinsockServer.GetData tmpstr
    TextGet.Text = tmpstr
  End Sub

⌨️ 快捷键说明

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