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

📄 form1.frm

📁 vb源码大全
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Server 
   Caption         =   "Form1"
   ClientHeight    =   3735
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3660
   LinkTopic       =   "Form1"
   ScaleHeight     =   3735
   ScaleWidth      =   3660
   StartUpPosition =   3  '窗口缺省
   Begin MSWinsockLib.Winsock UDPPeerB 
      Left            =   1560
      Top             =   2640
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
      Protocol        =   1
   End
   Begin VB.TextBox txtOutput 
      Height          =   2295
      Left            =   480
      MultiLine       =   -1  'True
      TabIndex        =   1
      Top             =   1200
      Width           =   2775
   End
   Begin VB.TextBox txtSend 
      Height          =   375
      Left            =   480
      ScrollBars      =   2  'Vertical
      TabIndex        =   0
      Top             =   480
      Width           =   2775
   End
   Begin VB.Label Label2 
      Caption         =   "接受来自客户端的消息:"
      Height          =   375
      Left            =   480
      TabIndex        =   3
      Top             =   960
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "请输入文本:"
      Height          =   255
      Left            =   480
      TabIndex        =   2
      Top             =   120
      Width           =   1335
   End
End
Attribute VB_Name = "Server"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'初始化UDP winsock插件
Private Sub Form_Load()
    With UDPPeerB
        .RemoteHost = "127.0.0.1" '要连接到的计算机名
        .RemotePort = 1011 '要连接到的端口号
        .LocalPort = 1010 '该Winsock控制将要使用的本地端口号,便于其他端与该Winsock通信
        .Bind 1010 '将该Winsock控制绑定到该本地端口
    End With
End Sub
'遇到回车发送信息
Private Sub txtSend_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        UDPPeerB.SendData txtSend.Text '发送文本
    End If
End Sub

'接收信息
Private Sub udpPeerB_DataArrival(ByVal bytesTotal As Long)
    Dim strData As String
    UDPPeerB.GetData strData, vbString
    txtOutput.Text = txtOutput.Text & strData
End Sub

⌨️ 快捷键说明

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