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

📄 硬件调试接受窗口.frm

📁 196kc作为下微机
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   8205
   ClientLeft      =   675
   ClientTop       =   1290
   ClientWidth     =   9750
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   8205
   ScaleWidth      =   9750
   Begin VB.CommandButton Command4 
      Caption         =   "自动取数据"
      Height          =   495
      Left            =   8280
      TabIndex        =   15
      Top             =   480
      Width           =   1215
   End
   Begin VB.CommandButton Command3 
      Caption         =   "已复位"
      Height          =   375
      Left            =   600
      TabIndex        =   14
      Top             =   360
      Width           =   855
   End
   Begin VB.TextBox Text2 
      Height          =   270
      Left            =   6120
      MultiLine       =   -1  'True
      TabIndex        =   12
      Top             =   2520
      Width           =   1695
   End
   Begin VB.CheckBox Check_hex 
      Caption         =   "十六进制显示"
      Height          =   375
      Left            =   3960
      TabIndex        =   11
      Top             =   4800
      Width           =   1575
   End
   Begin VB.TextBox Text_r 
      Height          =   2775
      Left            =   3720
      MultiLine       =   -1  'True
      TabIndex        =   10
      Top             =   5280
      Width           =   5295
   End
   Begin VB.CheckBox Check1 
      Height          =   255
      Left            =   1320
      TabIndex        =   8
      Top             =   1800
      Width           =   255
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   1320
      TabIndex        =   5
      Top             =   2160
      Width           =   375
   End
   Begin VB.Timer Timer1 
      Interval        =   300
      Left            =   120
      Top             =   1680
   End
   Begin VB.CommandButton Command2 
      Caption         =   "清空"
      Height          =   375
      Left            =   5760
      TabIndex        =   3
      Top             =   4800
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "send"
      Height          =   375
      Left            =   360
      TabIndex        =   1
      Top             =   960
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   2055
      Left            =   1920
      MultiLine       =   -1  'True
      TabIndex        =   0
      Top             =   360
      Width           =   5895
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   9120
      Top             =   7560
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      InputMode       =   1
   End
   Begin VB.Shape Shape1 
      BackStyle       =   1  'Opaque
      FillColor       =   &H0000FF00&
      FillStyle       =   0  'Solid
      Height          =   375
      Left            =   120
      Shape           =   3  'Circle
      Top             =   360
      Width           =   375
   End
   Begin VB.Label Label6 
      Caption         =   "发送字节"
      Height          =   195
      Left            =   4800
      TabIndex        =   13
      Top             =   2640
      Width           =   795
   End
   Begin VB.Label Label5 
      Caption         =   "(重值周期后再次选择自动发送)"
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   2760
      Width           =   2535
   End
   Begin VB.Label Label4 
      Caption         =   "自动发送"
      Height          =   255
      Left            =   360
      TabIndex        =   7
      Top             =   1920
      Width           =   735
   End
   Begin VB.Label Label3 
      Caption         =   "发送周期"
      Height          =   255
      Left            =   360
      TabIndex        =   6
      Top             =   2280
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "发送区"
      Height          =   255
      Left            =   2160
      TabIndex        =   4
      Top             =   120
      Width           =   615
   End
   Begin VB.Label Label1 
      Caption         =   "接受区"
      Height          =   255
      Left            =   3600
      TabIndex        =   2
      Top             =   4560
      Width           =   615
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetTickCount Lib "kernel32" _
() As Long
Public Sub TimeDelay(DT As Long)
  Dim tt As Long
  tt = GetTickCount()
  Do
    DoEvents
  Loop Until GetTickCount - tt >= DT
  
End Sub
Public Sub Send_Data(hh As Integer)
Dim mysend() As Byte
Dim sendbyte(1)  As Byte
Dim tempstr As String
Dim in_num As Integer

tempstr = Text1.Text
in_num = Len(tempstr)
ReDim mysend(1 To in_num) As Byte
For i = 1 To in_num
mysend(i) = Asc(Mid(tempstr, i, 1))
Next i


For ii = 1 To in_num
    sendbyte(0) = mysend(ii)
    MSComm1.Output = sendbyte '一个字节一发送    'mysend一串发'
    'TimeDelay (1)
    Shape1.FillColor = vbGreen
Next ii
    Shape1.FillColor = vbWhite
    
Text2.Text = Val(Text2.Text) + in_num

If Val(Text2.Text) > 100 Then
    Timer1.Enabled = False
    Text1.Text = "单片机存储超量,程序自动停止发送,请手动复位单片机"
    Shape1.FillColor = vbRed
    g_SendOverFg = True
End If

End Sub

Private Sub Check1_Click()
Dim sendhead(1) As Byte
If Check1.Value = 1 Then
    Timer1.Enabled = True
    Timer1.Interval = Val(Text3.Text) * 20
    
Else
    Timer1.Enabled = False
    
End If
End Sub

Private Sub Command3_Click() '已复位按钮

If g_SendOverFg = True Then
   Text2.Text = ""
   Text1.Text = g_InitialStr
   Shape1.FillColor = vbGreen
   g_SendOverFg = False
End If
   

End Sub

Private Sub Command4_Click() '--------auto_create_and_send_data-------------
Dim sendone(1) As Byte
Dim gewei As String
Dim shiwei As String
Dim num As Integer
g_flag = 4
gewei = 0
shiwei = 0

   sendone(0) = 33 '! 十进制表示asc码
    MSComm1.Output = sendone
    TimeDelay (10)     '延时等待单片机执行完8个周期
   
   gewei = Right((Trim(Text1.Text)), 1)
   If Len(Trim(Text1.Text)) = 2 Then
      shiwei = Left((Trim(Text1.Text)), 1)
   End If
   
   num = Val(shiwei) * 10 + Val(gewei)
   sendone(0) = num + 34   '协议: !=chr(33)表开始,"=chr(34)表示基准,asc和十进制转换
   
   MSComm1.OutBufferCount = 0
   MSComm1.Output = sendone
   'e r r o r F 6 1 1 0 5 1 2 3 4 6 1 1 0 : 1 2 3 4 6 1 1 0 ? 1 2 3 4 6 1 1 0 D 1 2 3 4 6 1 1 0 I 1 2 3 4 6 1 1 0 N 1 2 3 4 6 1 1 0 S 1 2 3 4 6 1 1 0 X 1 2 3 4 6 1 1 0 ] 1 2 3 4 6 1 1 0 b 1 2 3 4 6 1 1 0 g 1 2 3 4 6 1 1 0 l 1 2 3 4 6 1 1 1 q 1 2 3 4 6 1 1 2 v 1 2 3 4 6 1 1 3 { 1 2 3 4 6 1 1 4 

⌨️ 快捷键说明

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