📄 form1.vb
字号:
Imports soilnet.MobileNETLib
Namespace MobileNETLibTest
Public Class Form1
Inherits System.Windows.Forms.Form
Implements SoilNet.MobileNETLib.IStatus
'连接手机/GSM_Modem
'params:端口号,状态显示接口
Private WithEvents c As New T618ATCommand(5, Me)
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Button5 As System.Windows.Forms.Button
Friend WithEvents Button6 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.StatusBar1 = New System.Windows.Forms.StatusBar
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Button5 = New System.Windows.Forms.Button
Me.Button6 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(20, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ReadOnly = True
Me.TextBox1.Size = New System.Drawing.Size(428, 21)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(460, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(104, 23)
Me.Button1.TabIndex = 1
Me.Button1.Text = "发送AT命令"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(20, 48)
Me.TextBox2.Multiline = True
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.ReadOnly = True
Me.TextBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.TextBox2.Size = New System.Drawing.Size(588, 316)
Me.TextBox2.TabIndex = 2
Me.TextBox2.Text = ""
'
'StatusBar1
'
Me.StatusBar1.Location = New System.Drawing.Point(0, 368)
Me.StatusBar1.Name = "StatusBar1"
Me.StatusBar1.Size = New System.Drawing.Size(720, 22)
Me.StatusBar1.TabIndex = 3
Me.StatusBar1.Text = "StatusBar1"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(616, 148)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(96, 60)
Me.Button2.TabIndex = 4
Me.Button2.Text = "开始侦听手机键与短信到达提示"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(616, 220)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(96, 23)
Me.Button3.TabIndex = 5
Me.Button3.Text = "停止侦听"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(616, 48)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(96, 23)
Me.Button4.TabIndex = 6
Me.Button4.Text = "显示所有属性"
'
'Button5
'
Me.Button5.Location = New System.Drawing.Point(616, 80)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(96, 23)
Me.Button5.TabIndex = 7
Me.Button5.Text = "发送短信"
'
'Button6
'
Me.Button6.Location = New System.Drawing.Point(616, 112)
Me.Button6.Name = "Button6"
Me.Button6.Size = New System.Drawing.Size(96, 23)
Me.Button6.TabIndex = 8
Me.Button6.Text = "接收所有短信"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(720, 390)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.StatusBar1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.AppendText(c.TransactCommand(TextBox1.Text))
End Sub
Public Sub SetStatus(ByVal msg As String) Implements SoilNet.MobileNETLib.IStatus.SetStatus
StatusBar1.Text = msg
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If c.Open() Then
TextBox1.ReadOnly = False
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
c.StartListenKeyPress()
c.StartListenSMS()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
c.StopListenKeyPress()
c.StopListenSMS()
End Sub
'写日志
Public Sub WriteLog(ByVal msg As String) Implements SoilNet.MobileNETLib.IStatus.WriteLog
TextBox2.AppendText(msg & vbCrLf)
End Sub
'键盘事件
Private Sub c_OnKeyDown(ByVal key As T618ATCommand.T618Key) Handles c.OnKeyDown
TextBox2.AppendText(key.ToString & " KEY DOWN" & vbCrLf)
End Sub
Private Sub c_OnKeyUp(ByVal key As T618ATCommand.T618Key) Handles c.OnKeyUp
TextBox2.AppendText(key.ToString & " KEY UP" & vbCrLf)
End Sub
'显示所有预定义属性
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'MsgBox(c.GetGenricValue("CellRealTime", True))
'MsgBox(c.GetGenricValue("CIND_smsfull"))
'MsgBox(c.GetGenricValue("CellCurrentSMSNum"))
TextBox2.Clear()
Dim s As String
For Each s In c.PropertiesName
TextBox2.AppendText(s.PadRight(30) & c.GetGenricValue(s) & vbCrLf)
Next
End Sub
'发送一条短信
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
c.SendSMS("1861", "yecx")
End Sub
'读取收有短信
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim ss() As SMSItem
ss = c.GetALLSMS(ReadFromEnum.Phone, ReadSMSType.ALL)
Dim s As SMSItem
For Each s In ss
TextBox2.AppendText(s.SendNumber & vbCrLf)
TextBox2.AppendText(s.ReceiveTime & vbCrLf)
TextBox2.AppendText(s.SMSType.ToString & vbCrLf)
TextBox2.AppendText(s.SMSContent & vbCrLf & vbCrLf & vbCrLf)
Next
End Sub
'读取第N条短信
'Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
' Dim s As SMSItem = c.ReadSMSByIndex(ReadFromEnum.Phone, 6)
' TextBox2.AppendText(s.SendNumber & vbCrLf)
' TextBox2.AppendText(s.ReceiveTime & vbCrLf)
' TextBox2.AppendText(s.SMSContent & vbCrLf)
'End Sub
'收到短信时的提示信息
Private Sub c_OnReceivedSMS(ByVal From As ReadFromEnum, ByVal Index As Integer) Handles c.OnReceivedSMS
MsgBox("You have New SMS!")
End Sub
'双击清除
Private Sub TextBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.DoubleClick
TextBox2.Clear()
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Try
Application.Exit()
End
Catch ex As Exception
End Try
End Sub
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -