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

📄 frmliumax.frm

📁 远程水文监测系统 利用vb通信实现远程监控功能。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Frmliumax 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "电流最大值设定"
   ClientHeight    =   2640
   ClientLeft      =   3960
   ClientTop       =   3585
   ClientWidth     =   4185
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2640
   ScaleWidth      =   4185
   Begin VB.Timer Timer2 
      Interval        =   650
      Left            =   120
      Top             =   1560
   End
   Begin VB.CommandButton CommandQuit 
      Caption         =   "返回"
      Height          =   375
      Left            =   2520
      TabIndex        =   3
      Top             =   1680
      Width           =   1095
   End
   Begin VB.CommandButton CommandOK 
      Caption         =   "确定"
      Height          =   375
      Left            =   1200
      TabIndex        =   2
      Top             =   1680
      Width           =   1095
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   650
      Left            =   600
      Top             =   1560
   End
   Begin VB.ComboBox ComboValue 
      Height          =   300
      Left            =   2040
      TabIndex        =   1
      Top             =   1080
      Width           =   1455
   End
   Begin VB.TextBox TextTel 
      Height          =   405
      Left            =   2040
      TabIndex        =   0
      Top             =   360
      Width           =   1815
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "远端设备号码:"
      BeginProperty Font 
         Name            =   "新宋体"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000007&
      Height          =   375
      Left            =   360
      TabIndex        =   5
      Top             =   480
      Width           =   1695
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "电流最大值:"
      BeginProperty Font 
         Name            =   "新宋体"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000007&
      Height          =   375
      Left            =   600
      TabIndex        =   4
      Top             =   1080
      Width           =   1575
   End
End
Attribute VB_Name = "Frmliumax"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As New ADODB.Recordset

Dim intall As Integer



Private Sub CommandOK_Click()
On Error Resume Next
If ComboValue.Text <> "" Then
   MDIForm1.Comm1.Output = "AT+CMGS=" + TextTel.Text + Chr(13) + Chr(13) + Chr(10)
   '使用主界面上的MSComm控件进行发送AT指令,注意发送AT指令必须以两个回车和一个换行符号结束
   Timer1.Enabled = True
Else
MsgBox "请设定电流的最大值!", vbOKOnly, "通知"
End If
End Sub

Private Sub CommandQuit_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim i As Integer
i = 0
While i <= 1000          '使用循环往ComboBox控件中插入数据
ComboValue.AddItem (i)
i = i + 10
Wend


End Sub






Private Sub Timer1_Timer()
On Error Resume Next
Dim Buf$
Dim StrChk$
Dim IntMax As Integer     '存放设定的最大值
Dim IntHigh, IntChk As Integer
Dim IntLow As Integer

IntMax = CInt(ComboValue.Text)  '设定的最大值,ComboBox中的字符串类型强制转换为Integer
IntHigh = IntMax \ 100      '最大值的高位
IntLow = IntMax Mod 100     '最大值的低位
IntChk = IntHigh + IntLow + 1  '校验和,加的1是命令码,代表设定电压最大值的意思
While IntChk > 127   '循环减去128,相当于2进制的取模运算
IntChk = IntChk - 128
Wend

 
If MDIForm1.Comm1.InBufferCount > 20 Then
MDIForm1.Comm1.InputLen = 0
  Timer1.Enabled = False
  Buf = Trim(MDIForm1.Comm1.Input)  'buf中存放着从串口中读取的所有确认信息
  StrChk = Right(Buf, 1)
  If StrChk = ">" Then    '判断收到的确认信息的最后一位是否为字符“>”,
                           '如果是,代表GSM模块已准备好接受数据
      MDIForm1.Comm1.Output = "%%" + Chr(1) + Chr(IntHigh) + Chr(IntLow) + Chr(IntChk) + "%" + Chr(26)
                        '根据数据协议,数据采取以%%开头和%结束,数据的末尾必须加上ctrl-z以结束
     Timer1.Enabled = False
     Timer2.Enabled = True
      End If
End If
End Sub

Private Sub Timer2_Timer()
On Error Resume Next
'读取发送信息后的确认信息,“OK”代表完成。
Dim arr_return() As Variant   '存放读取的确认信息
Dim IntTmep As Integer
IntTmep = 0
If MDIForm1.Comm1.InBufferCount > 20 Then
Timer2.Enabled = False
While MDIForm1.Comm1.InBufferCount > 0   '循环的读取确认信息
MDIForm1.Comm1.InputLen = 1    '设置MSComm控件的InputLen属性为一,即一个字节一个字节的读取
ReDim Preserve arr_return(IntTmep + 1)  '动态的改变数组的范围
arr_return(IntTmep) = Hex(Asc(MDIForm1.Comm1.Input))
IntTmep = IntTmep + 1
Wend

  If arr_return(IntTmep - 4) = Hex(Asc("O")) And arr_return(IntTmep - 3) = Hex(Asc("K")) Then

       MsgBox "电流的最大值已经设定完毕!", vbOKOnly, "通知"

  End If
End If
End Sub

⌨️ 快捷键说明

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