2、在项目事件AfterOpenProject设置代码:
FoxSms.SyncWorkMode = False
'设置为异步工作模式
FoxSMS.CommPort = 3
'注意端口号千万不能搞错
FoxSMS.OpenCom()
3、在项目事件BeforeCloseProject事件中设置代码:
FoxSMS.CloseCom()
4、然后在短信监视器中,设置ConnectModemResult事件的代码为:
If
e.Succeed =
False Then
MessageBox.Show("短信猫连接失败!","提示",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
End
If
5、然后在短信监视器中,设置NewMessage事件的代码为:
If
e.Content.StartsWith("**")
Then
'如果信息是以约定的**开始
Dim
vals() As
String = e.Content.Trim("*").Split("*")
Dim ret
As
String
Dim
flt As
String
For
Each val
As
String
In vals
If flt > ""
Then
flt = flt &
","
End
If
flt = flt &
"'" & val &
"'"
Next
If
flt > "" Then
Dim drs
As
List(Of
DataRow) =
DataTables("库存").Select("产品
In (" & flt & ")")
For
Each dr
As
DataRow
In drs
If
ret > "" Then
ret = ret & vbcrlf
End
If
ret = ret &
"产品:"
& dr("产品") &
" 库存:" & dr("数量")
& " 单价:" & dr("单价")
Next
If ret = ""
Then
ret =
"无此产品:"
& e.Content
End
If
Else
ret =
"格式错误:"
& e.Content
End
If
FoxSms.DelMsgForIndex(e.Index)
'从SIM卡删除此短信
FoxSMS.SendMsg(e.FromNumber,ret)
End
If