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

📄 frmsendstr.frm

📁 此程序为标准的TCPIP网络编程
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmSendStr 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "循环发送字符串"
   ClientHeight    =   2670
   ClientLeft      =   5805
   ClientTop       =   2955
   ClientWidth     =   5520
   Icon            =   "frmSendStr.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2670
   ScaleWidth      =   5520
   ShowInTaskbar   =   0   'False
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   2640
      Top             =   0
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   375
      Left            =   4320
      TabIndex        =   10
      Top             =   2160
      Width           =   975
   End
   Begin VB.CommandButton CmdStartStr 
      Caption         =   "开始发送"
      Height          =   375
      Left            =   3120
      TabIndex        =   9
      Top             =   2160
      Width           =   975
   End
   Begin VB.Frame Frame2 
      Caption         =   "参数设置"
      Height          =   1215
      Left            =   3120
      TabIndex        =   2
      Top             =   120
      Width           =   2295
      Begin VB.TextBox TxtCount 
         Alignment       =   2  'Center
         Height          =   285
         Left            =   960
         TabIndex        =   6
         Text            =   "5"
         Top             =   825
         Width           =   735
      End
      Begin VB.TextBox TxtInterval 
         Alignment       =   2  'Center
         BeginProperty DataFormat 
            Type            =   0
            Format          =   "1234567890"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
         Height          =   285
         Left            =   960
         MaxLength       =   5
         TabIndex        =   4
         Text            =   "1000"
         Top             =   345
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "次"
         Height          =   255
         Left            =   1800
         TabIndex        =   8
         Top             =   840
         Width           =   255
      End
      Begin VB.Label Label2 
         Caption         =   "毫秒"
         Height          =   255
         Left            =   1800
         TabIndex        =   7
         Top             =   360
         Width           =   375
      End
      Begin VB.Label Label3 
         Caption         =   "发送次数"
         Height          =   255
         Left            =   120
         TabIndex        =   5
         Top             =   840
         Width           =   855
      End
      Begin VB.Label Label1 
         Caption         =   "时间间隔"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   360
         Width           =   735
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "循环发送的字符串"
      Height          =   2415
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2895
      Begin VB.TextBox TxtCycStr 
         BeginProperty DataFormat 
            Type            =   0
            Format          =   "0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1935
         Left            =   120
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   1
         Top             =   360
         Width           =   2655
      End
   End
   Begin MSComctlLib.ProgressBar ProgressBar1 
      Height          =   255
      Left            =   3240
      TabIndex        =   11
      Top             =   1440
      Width           =   2055
      _ExtentX        =   3625
      _ExtentY        =   450
      _Version        =   393216
      BorderStyle     =   1
      Appearance      =   0
      Enabled         =   0   'False
      Scrolling       =   1
   End
   Begin VB.Label LblStatus 
      Alignment       =   2  'Center
      Caption         =   "准备发送..."
      Height          =   255
      Left            =   3360
      TabIndex        =   12
      Top             =   1800
      Width           =   1815
   End
End
Attribute VB_Name = "frmSendStr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sCount As Long '剩下要发送的次数

Private Sub CmdStartStr_Click()

Dim tInterval As Integer '时间间隔
Dim sTotalCount As Long '发送的总次数

tInterval = TxtInterval.Text
sTotalCount = TxtCount.Text

Timer1.Enabled = True
Timer1.Interval = tInterval

sCount = sTotalCount

ProgressBar1.Max = sTotalCount
ProgressBar1.Value = 0

CmdStartStr.Enabled = False
End Sub

Private Sub Command2_Click()
'If Timer1.Enabled Then
'    MsgBox "当前正在传送数据,这将导致数据传输中止。"
'End If
Unload Me
End Sub

Private Sub Form_Load()
    Me.Left = frmMain.Left + frmMain.Width - Me.Width
    Me.Top = frmMain.Top
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Timer1.Enabled Then
    MsgBox "当前正在传送数据,这将导致数据传输中止。"
End If
Unload Me
End Sub

'每隔一定的时间间隔发送一次
Private Sub Timer1_Timer()
If sCount > 0 Then
    If frmMain.Winsock1.State = 7 Or (frmMain.Winsock1.Protocol = sckUDPProtocol And udpEnabled) Then
       ' frmMain.Winsock1.sendData TxtCycStr.Text
        frmMain.WinsockSend TxtCycStr.Text
        sendLen = sendLen + ByteLen(TxtCycStr.Text)
        frmMain.StatusBar1.Panels(3).Text = "发送:" & sendLen
        
        sCount = sCount - 1
        
        '显示状态
        LblStatus.Caption = (ProgressBar1.Value + 1) & "/" & ProgressBar1.Max
        '控制进度条
        ProgressBar1.Value = ProgressBar1.Max - sCount
        
    Else
        MsgBox "网络没有连接,因此不能操作!请检查网络是否通畅。"
        Timer1.Enabled = False
    End If
    If sCount <= 0 Then
        Timer1.Enabled = False
        sCount = 0
        LblStatus.Caption = "发送完毕!"
        CmdStartStr.Enabled = True
    End If
End If
End Sub

⌨️ 快捷键说明

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