📄 frmset.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmSet
BorderStyle = 1 'Fixed Single
Caption = "TC35终端设置"
ClientHeight = 1620
ClientLeft = 45
ClientTop = 330
ClientWidth = 7245
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmSet.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1620
ScaleWidth = 7245
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame
Height = 1185
Left = 5460
TabIndex = 11
Top = 210
Width = 30
End
Begin VB.ComboBox lstSP
Height = 300
Left = 1500
Style = 2 'Dropdown List
TabIndex = 10
Top = 1080
Width = 3615
End
Begin VB.TextBox txtTelphone
Height = 285
Left = 1530
MaxLength = 20
TabIndex = 8
Top = 660
Width = 3525
End
Begin MSComCtl2.UpDown udPort
Height = 270
Left = 4830
TabIndex = 6
Top = 240
Width = 240
_ExtentX = 423
_ExtentY = 476
_Version = 393216
Value = 1
BuddyControl = "txtPort"
BuddyDispid = 196612
OrigLeft = 4950
OrigTop = 240
OrigRight = 5190
OrigBottom = 555
Max = 20
Min = 1
SyncBuddy = -1 'True
BuddyProperty = 65547
Enabled = -1 'True
End
Begin VB.TextBox txtPort
Height = 270
Left = 4290
Locked = -1 'True
MaxLength = 2
TabIndex = 5
Text = "1"
Top = 240
Width = 465
End
Begin VB.TextBox txtServiceTelphone
Height = 285
Left = 1530
MaxLength = 20
TabIndex = 3
Text = "13800755500"
Top = 240
Width = 2085
End
Begin VB.CommandButton bntCancel
Caption = "取消"
Height = 375
Left = 5820
TabIndex = 1
Top = 690
Width = 1155
End
Begin VB.CommandButton bntOK
Caption = "确定"
Height = 375
Left = 5820
TabIndex = 0
Top = 240
Width = 1155
End
Begin VB.Label Label
AutoSize = -1 'True
Caption = "发送SM服务商:"
Height = 180
Index = 3
Left = 300
TabIndex = 9
Top = 1140
Width = 1170
End
Begin VB.Label Label
AutoSize = -1 'True
Caption = "TC35内置卡号:"
Height = 180
Index = 2
Left = 300
TabIndex = 7
Top = 660
Width = 1170
End
Begin VB.Label Label
AutoSize = -1 'True
Caption = "端口:"
Height = 180
Index = 1
Left = 3720
TabIndex = 4
Top = 300
Width = 450
End
Begin VB.Label Label
AutoSize = -1 'True
Caption = "服务中心号码:"
Height = 180
Index = 0
Left = 300
TabIndex = 2
Top = 270
Width = 1170
End
End
Attribute VB_Name = "frmSet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private TC35ID As Long
Private SpID As Long
Dim isChange As Boolean
Dim xml As String
Dim v_ErrMsg As String
Private Sub bntCancel_Click()
Unload Me
End Sub
Private Sub bntOK_Click()
Dim s As String
Dim ErrMsg As String
s = checkTelphone(txtServiceTelphone.Text, "发送SM的服务中心")
If s = "" Then
ShowMsg v_ErrMsg
txtServiceTelphone.SetFocus
Exit Sub
End If
s = Trim(Trim(txtPort.Text))
If s = "" Then
ShowMsg "发送短信的端口号不能为空值!"
txtPort.SetFocus
Exit Sub
End If
If Not IsNumeric(s) Then
ShowMsg "发送短信的端口号必须为数值型!"
txtPort.SetFocus
Exit Sub
End If
Dim n As Long
n = CLng(txtPort.Text)
If n < 1 Or m > 20 Then
ShowMsg "发送短信的端口号必须为1-20之间!"
txtPort.SetFocus
Exit Sub
End If
If txtTelphone.Text <> "" Then
s = checkTelphone(txtTelphone.Text, "内置SIM")
If s = "" Then
ShowMsg v_ErrMsg
txtTelphone.SetFocus
Exit Sub
End If
End If
OpenCN
OpenRS
If TC35ID = 0 Then
rs.Open "Select * from School_tc35", cn, 3, 3
rs.AddNew
Else
rs.Open "Select * from School_tc35 where TC35ID=" & TC35ID, cn, 3, 3
If rs.EOF Then
Err.Raise -1, , "TC35短信终端没找到,可能是已经被用户删除"
End If
End If
rs("SpID") = getListValue(lstSP)
rs("Port") = txtPort.Text
rs("ServiceTelphone") = txtServiceTelphone.Text
rs("Telphone") = txtTelphone.Text
rs.Update
CloseRS rs
Dim li As ListItem
If TC35ID = 0 Then
TC35ID = getIdentity()
Set li = frmMain.ListView.ListItems.Add(, "T_" & TC35ID, txtPort.Text)
Else
Set li = frmMain.ListView.ListItems("T_" & TC35ID)
End If
Dim t() As String
t = Split(lstSP.Text, " - ")
li.Text = txtPort.Text
li.SubItems(1) = txtServiceTelphone.Text
li.SubItems(3) = t(0)
li.SubItems(4) = t(1)
CloseCN
isChange = True
Unload Me
Exit Sub
laberr:
ShowMsg "保存TC35短信终端出错,错误信息为" & Err.Description
CloseRS rs
CloseCN
xml = ""
End Sub
Private Sub Form_Load()
DlgInit isChange, xml
TC35ID = dlgPara.ID
If TC35ID <> 0 Then
Load
Else
SpID = 1
TC35ID = 0
End If
loadSPToListBox lstSP, SpID
bntOK.Enabled = Not frmMain.bntSTOP.Enabled
End Sub
Private Sub Load()
On Error GoTo laberr
'Dim rs As ADODB.Recordset
OpenCN
Set rs = cn.Execute("select Top 1 * from School_TC35 where TC35id=" & TC35ID)
If rs.EOF Then
Err.Raise -1, , "TC35设备信息没找到。"
End If
txtServiceTelphone.Text = rs("ServiceTelphone") & ""
txtPort.Text = rs("Port") & ""
SpID = rs("spID")
txtTelphone.Text = rs("Telphone") & ""
'chkIsUsed.Value = IIf(rs("isused"), 1, 0)
CloseCN
Exit Sub
laberr:
ShowMsg "读入TC35设备信息时出错,错误信息为" & Err.Description
bntOK.Enabled = False
CloseRS rs
CloseCN
End Sub
'检查手机号码是否正确,若正确返回加入了国别或者接受者信息的号码,否则为空字符串值,此时v_ErrMsg表示错误信息
Private Function checkTelphone(ByVal Mobile As String, _
Optional ByVal Name As String = "手机") As String
Dim c As String
Dim n As Integer
Dim i As Integer
checkTelphone = ""
n = Len(Mobile)
If n < 7 Then
v_ErrMsg = Name & "号码长度必须大于或等于7。"
Else
If Left(Mobile, 2) = "13" Then
If n <> 11 Then
v_ErrMsg = Name & "(当前为手机)号码[" & Mobile & "]必须由11位数字组成."
Exit Function
Else
For i = 1 To 11
c = Mid(Mobile, i, 1)
If c < "0" Or c > "9" Then
v_ErrMsg = Name & "(当前为手机)号码[" & Mobile & "]必须由11位数字组成."
Exit Function
End If
Next i
v_ErrMsg = ""
checkTelphone = "86" & Mobile
End If
Else
For i = 1 To n
c = Mid(Mobile, i, 1)
If c < "0" Or c > "9" Then
v_ErrMsg = Name & "号码[" & Mobile & "]必须由11或12位数字组成."
Exit Function
End If
Next i
v_ErrMsg = ""
checkTelphone = Mobile
End If
End If
End Function
Private Sub loadSPToListBox(li As Object, Optional ByVal SpID As Long = -1)
On Error GoTo laberr
Dim rs As ADODB.Recordset
li.Clear
OpenCN
Set rs = cn.Execute("select Spid,Name+' - '+ Prex as Name from Dict_SP")
While Not rs.EOF
li.AddItem rs(1)
If SpID = rs(0) Then
li.ListIndex = li.NewIndex
End If
li.ItemData(li.NewIndex) = rs(0)
rs.MoveNext
Wend
If li.ListIndex = -1 Then
If li.ListCount > 0 Then li.ListIndex = 0
End If
CloseRS rs
CloseCN
Exit Sub
laberr:
CloseRS rs
CloseCN
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -