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

📄 form1.frm

📁 本程序客户端可以实现学生对号入座
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1 
   BackColor       =   &H00FF0000&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   750
   ClientLeft      =   4230
   ClientTop       =   465
   ClientWidth     =   3810
   LinkTopic       =   "Form1"
   ScaleHeight     =   750
   ScaleWidth      =   3810
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton Command1 
      Caption         =   "退出"
      Height          =   255
      Left            =   3240
      TabIndex        =   2
      Top             =   120
      Width           =   495
   End
   Begin MSWinsockLib.Winsock Winsock1 
      Left            =   0
      Top             =   0
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Label2"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   21.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0080C0FF&
      Height          =   495
      Left            =   1680
      TabIndex        =   1
      Top             =   120
      Width           =   2055
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Label1"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   21.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FFFF&
      Height          =   495
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   1335
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim flag As Boolean
Dim sendstr As String
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Sub Command1_Click()
Unload Me
End
End Sub

Private Sub Form_Load()
Dim jqm As String
SetTopMostWindow = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
Me.Top = 0
Me.Left = Screen.Width / 2 - Me.Width / 2
jqm = Winsock1.LocalHostName
Label1.Caption = jqm
sendstr = "LOG|" + Trim(jqm)
Call init
End Sub

Private Sub init()
  On Error GoTo errhandle:
  If Winsock1.State <> 0 Then
  Winsock1.Close
  End If
    Winsock1.RemoteHost = "127.0.0.1"         '服务器IP地址
    Winsock1.RemotePort = 5200         '服务器侦听断口(接收数据的端口)
    Winsock1.Connect
 Exit Sub
errhandle:
    MsgBox Err.Description
End Sub

Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub

Private Sub winsock1_Connect()
    Winsock1.SendData sendstr
End Sub

Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)     '收到来自服务器端的信息时,发生该事件
Dim strData As String
Dim k As Integer, sData() As String
    Winsock1.GetData strData                                     '接收来自服务器的信息,保存在变量sData中
    sData = Split(strData, "|")
 Select Case UCase(sData(0))
    Case "DLFK"                                         '如果数据的第一位是“^”,说明是客户端作出了退出申请
        Label2.Caption = sData(1) & sData(2)
          If Winsock1.State <> sckClosed Then
             Winsock1.Close
          End If
 End Select
         Exit Sub
errhandle:
    MsgBox Err.Description
End Sub

⌨️ 快捷键说明

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