📄 form1.frm
字号:
Top = 4200
Width = 14655
Begin VB.CheckBox Check4
Caption = "显示时间"
Height = 375
Left = 12960
TabIndex = 32
Top = 1320
Value = 1 'Checked
Width = 1215
End
Begin VB.CheckBox Check3
Caption = "显示日期"
Height = 375
Left = 11280
TabIndex = 31
Top = 1320
Value = 1 'Checked
Width = 1215
End
Begin VB.CheckBox Check2
Caption = "显示IMEI"
Height = 375
Left = 12960
TabIndex = 30
Top = 720
Value = 1 'Checked
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "读取接收记录"
Height = 495
Left = 8760
TabIndex = 25
Top = 2160
Width = 1455
End
Begin VB.CheckBox Check1
Caption = "显示数据"
Height = 375
Left = 11280
TabIndex = 7
Top = 720
Value = 1 'Checked
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "保存接收记录"
Height = 495
Left = 8760
TabIndex = 6
Top = 1320
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "清除接收记录"
Height = 495
Left = 8760
TabIndex = 5
Top = 480
Width = 1455
End
Begin VB.TextBox Text1
Height = 2655
Left = 120
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 3
Top = 360
Width = 8175
End
End
Begin VB.Frame Frame1
Caption = "数据收发状态:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3135
Left = 240
TabIndex = 0
Top = 960
Width = 8415
Begin VB.TextBox Text10
BackColor = &H80000004&
Height = 2655
Left = 120
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 29
Top = 360
Width = 8175
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_Change()
If Combo1.ItemData = 0 Then
Text8.Text = "000000000000000"
Text8.Enabled = False
Text8.BackColor = &H80000004
End If
End Sub
Private Sub Command1_Click() '清除接收记录
Text1.Text = ""
End Sub
Private Sub Command10_Click()
Dim m_text As String
Dim m_str As String
Dim FileNumber As Integer
With CommonDialog1
.DialogTitle = "打开状态记录"
.Filter = "记录文件(*.log)|*.log|All Files|*.*"
End With
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
If FileName = "" Then
Exit Sub
End If
FileNumber = FreeFile
Open FileName For Input As FileNumber
Do While Not EOF(FileNumber)
Line Input #FileNumber, m_str
m_text = m_text + m_str + Chr(13) + Chr(10)
Loop
Close FileNumber
Text10.Text = m_text
End Sub
Private Sub Command2_Click() '保存接收记录
Dim Savename As String
Dim S As String
Dim Filenum As Integer
S = "R" + CStr(Date) + "_" + Replace(CStr(Time), ":", "-")
With CommonDialog1
.DefaultExt = "log"
.FileName = S
.DialogTitle = "保存接收记录"
.Filter = "记录文件(*.log)|*.log|All Files|*.*"
End With
CommonDialog1.ShowSave
Savename = CommonDialog1.FileName
Filenum = FreeFile()
Open Savename For Output As Filenum
Print #Filenum, Text1.Text
Close #Filenum
End Sub
Private Sub Command3_Click() '打开接收记录
Dim m_text As String
Dim m_str As String
Dim FileNumber As Integer
With CommonDialog1
.DialogTitle = "打开接收记录"
.Filter = "记录文件(*.log)|*.log|All Files|*.*"
End With
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
If FileName = "" Then
Exit Sub
End If
FileNumber = FreeFile
Open FileName For Input As FileNumber
Do While Not EOF(FileNumber)
Line Input #FileNumber, m_str
m_text = m_text + m_str + Chr(13) + Chr(10)
Loop
Close FileNumber
Text1.Text = m_text
End Sub
Private Sub Command4_Click() '清除发送记录
Text2.Text = ""
End Sub
Private Sub Command5_Click() '保存发送记录
Dim Savename As String
Dim S As String
Dim Filenum As Integer
S = "S" + CStr(Date) + "_" + Replace(CStr(Time), ":", "-")
With CommonDialog1
.DefaultExt = "log"
.FileName = S
.DialogTitle = "保存发送记录"
.Filter = "记录文件(*.log)|*.log|All Files|*.*"
End With
CommonDialog1.ShowSave
Savename = CommonDialog1.FileName
Filenum = FreeFile()
Open Savename For Output As Filenum
Print #Filenum, Text2.Text
Close
End Sub
Private Sub Command6_Click() '打开发送记录
Dim m_text As String
Dim m_str As String
Dim FileNumber As Integer
With CommonDialog1
.DialogTitle = "打开发送记录"
.Filter = "记录文件(*.log)|*.log|All Files|*.*"
End With
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
If FileName = "" Then
Exit Sub
End If
FileNumber = FreeFile
Open FileName For Input As FileNumber
Do While Not EOF(FileNumber)
Line Input #FileNumber, m_str
m_text = m_text + m_str + Chr(13) + Chr(10)
Loop
Close FileNumber
Text2.Text = m_text
End Sub
Private Sub Command7_Click()
Call fasongshuju
End Sub
Private Sub Command8_Click() '清除状态记录
Text10.Text = ""
End Sub
Private Sub Command9_Click() '保存状态记录
Dim Savename As String
Dim S As String
Dim Filenum As Integer
S = "All" + CStr(Date) + "_" + Replace(CStr(Time), ":", "-")
With CommonDialog1
.DefaultExt = "log"
.FileName = S
.DialogTitle = "保存状态记录"
.Filter = "记录文件(*.log)|*.log|All Files|*.*"
End With
CommonDialog1.ShowSave
Savename = CommonDialog1.FileName
Filenum = FreeFile()
Open Savename For Output As Filenum
Print #Filenum, Text10.Text
Close #Filenum
End Sub
Private Sub Form_Load()
mode = MODE_TCP
dc_ip = Text5.Text
dc_port = Text7.Text
block = MODE_NONBLOCK '读取默认参数
If Option3.Value = True Then
Text8.Text = "000000000000000"
Text8.BackColor = &H80000004
Text8.Enabled = False
End If
End Sub
Private Sub Label10_Click()
End Sub
Private Sub Option1_Click()
mode = MODE_TCP
End Sub
Private Sub Option2_Click()
mode = MODE_UDP
End Sub
Private Sub Option3_Click()
Text8.Text = "000000000000000"
Text8.BackColor = &H80000004
Text8.Enabled = False
End Sub
Private Sub Option4_Click()
Text8.Text = ""
Text8.BackColor = &H80000009
Text8.Enabled = True
End Sub
Private Sub Text5_Change()
dc_ip = Text5.Text
End Sub
Private Sub Timer1_Timer()
Dim fjieshou As Long
Dim msgjieshou As dc_msg
Dim S As String
Dim I, J As Integer
Dim dtudata As String
Dim dtuimei As String
dtudata = ""
dtuimei = ""
If dcc_hdl > 0 Then
Do '接受数据
fjieshou = dcc_msg_receive(dcc_hdl, msgjieshou)
If (fjieshou <= 0) Then Exit Do
S = ""
dtudata = ""
For I = 1 To 15 '获取 DTU的IMEI
S = S + Chr(msgjieshou.ImeiDTU(I))
Next I
dtuimei = S
For I = 1 To msgjieshou.msg_len '获取消息
dtudata = dtudata + Chr(msgjieshou.msg_body(I))
Next I
Select Case msgjieshou.msg_type '分析消息类型
Case 0 '接收到的是数据
S = "接收到 : " + S + " 的数据 : " + dtudata
Call xianshijieshou(dtudata, dtuimei)
Case 1
S = S + " 终端上线!" + Chr(13) + Chr(10)
Case 2
S = S + " 终端下线!" + Chr(13) + Chr(10)
Case 4
If msgjieshou.msg_body(1) = 0 Then
S = S + " 发送结果 : 成功!"
ElseIf msgjieshou.msg_body(1) = 1 Then
S = S + " 发送结果 : 终端不存在!"
ElseIf msgjieshou.msg_body(1) = 2 Then
S = S + " 发送结果 : 终端没上线!"
ElseIf msgjieshou.msg_body(1) = 3 Then
S = S + " 发送结果 : 终端拥塞,需要重发!"
Else
End If
Case 5
If msgjieshou.msg_body(1) = 0 Then
S = S + " 终端状态 不存在!"
ElseIf msgjieshou.msg_body(1) = 1 Then
S = S + " 终端状态 上线! IP地址:" + CStr(msgjieshou.msg_body(2)) + "." + _
CStr(msgjieshou.msg_body(3)) + "." + CStr(msgjieshou.msg_body(4)) + "." + _
CStr(msgjieshou.msg_body(5))
ElseIf msgjieshou.msg_body(1) = 2 Then
S = S + " 终端状态 没上线!"
Else
End If
Case 10
S = " AT命令 " + S + " " + dtudata
Form2.Text3.Text = S
Case Else
End Select
Call xianshizhuangtai(S)
Text10.SelStart = 32 * 1000 - 1
Loop While (fjieshou > 0)
End If
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "Kaishi" '开始连接
Call kaishilianjie
Case "Duankai" '断开连接
Call duankailianjie
Case "Fenli" '分离终端
Call fenlizhongduan
Case "Huoqu" '获取终端状态信息
Call huoquzhuangtai
Case "Mingling" '发送AT命令
Load Form2
Form2.Show
Case "Bangzhu" '帮助相关
MsgBox "数据中心客户端演示程序" + Chr(13) + Chr(10) + _
Chr(13) + Chr(10) + "版权所有 (C) 2007-3-5" + Chr(13) + Chr(10) + _
Chr(13) + Chr(10) + " 中国 北京 ", vbOKOnly + vbInformation, "帮助"
Case "Tuichu" ' 退出dcc演示程序
flag = MsgBox("是否退出程序?", vbYesNoCancel + vbQuestion, "提示")
If flag = vbYes Then
Call dcc_close(dcc_hdl) ' 释放连接
End
End If
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -