?? frmliumax.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 + -