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

📄 smscontrol1.ctl

📁 通过手机串口发送短信的VB控件代码,在NOKIA等手机上已经通过测试.
💻 CTL
📖 第 1 页 / 共 3 页
字号:
Public Property Get CommPort() As Integer
Attribute CommPort.VB_Description = "设置/返回通讯端口号。"
    CommPort = MSComm1.CommPort
End Property

Public Property Let CommPort(ByVal New_CommPort As Integer)
    MSComm1.CommPort() = New_CommPort
    PropertyChanged "CommPort"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtMsg,txtMsg,-1,Font
Public Property Get Font() As Font
Attribute Font.VB_Description = "返回一个 Font 对象。"
Attribute Font.VB_UserMemId = -512
    Set Font = txtMsg.Font
End Property

Public Property Set Font(ByVal New_Font As Font)
    Set txtMsg.Font = New_Font
    PropertyChanged "Font"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtMsg,txtMsg,-1,FontBold
Public Property Get FontBold() As Boolean
Attribute FontBold.VB_Description = "返回/设置粗体字样式。"
    FontBold = txtMsg.FontBold
End Property

Public Property Let FontBold(ByVal New_FontBold As Boolean)
    txtMsg.FontBold() = New_FontBold
    PropertyChanged "FontBold"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtMsg,txtMsg,-1,FontItalic
Public Property Get FontItalic() As Boolean
Attribute FontItalic.VB_Description = "返回/设置斜体字样式。"
    FontItalic = txtMsg.FontItalic
End Property

Public Property Let FontItalic(ByVal New_FontItalic As Boolean)
    txtMsg.FontItalic() = New_FontItalic
    PropertyChanged "FontItalic"
End Property
'
''注意!不要删除或修改下列被注释的行!
''MappingInfo=txtMsg,txtMsg,-1,FontName
'Public Property Get FontName() As String
'    FontName = txtMsg.FontName
'End Property
'
'Public Property Let FontName(ByVal New_FontName As String)
'    txtMsg.FontName() = New_FontName
'    PropertyChanged "FontName"
'End Property
'
''注意!不要删除或修改下列被注释的行!
''MappingInfo=txtMsg,txtMsg,-1,FontSize
'Public Property Get FontSize() As Single
'    FontSize = txtMsg.FontSize
'End Property
'
'Public Property Let FontSize(ByVal New_FontSize As Single)
'    txtMsg.FontSize() = New_FontSize
'    PropertyChanged "FontSize"
'End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,ForeColor
Public Property Get ForeColor() As OLE_COLOR
Attribute ForeColor.VB_Description = "返回/设置对象中文本和图形的前景色。"
    ForeColor = UserControl.ForeColor
End Property

Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
    UserControl.ForeColor() = New_ForeColor
    PropertyChanged "ForeColor"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,Enabled
Public Property Get Enabled() As Boolean
Attribute Enabled.VB_Description = "返回/设置一个值,决定一个对象是否响应用户生成事件。"
Attribute Enabled.VB_ProcData.VB_Invoke_Property = ";外观"
Attribute Enabled.VB_UserMemId = -514
    Enabled = UserControl.Enabled
End Property

Public Property Let Enabled(ByVal New_Enabled As Boolean)
    UserControl.Enabled() = New_Enabled
    PropertyChanged "Enabled"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=cmdSend,cmdSend,-1,Default
Public Property Get Default() As Boolean
Attribute Default.VB_Description = "决定窗体的缺省命令按钮。"
    Default = cmdSend.Default
End Property

Public Property Let Default(ByVal New_Default As Boolean)
    cmdSend.Default() = New_Default
    PropertyChanged "Default"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,BackStyle
Public Property Get BackStyle() As Integer
Attribute BackStyle.VB_Description = "指出 Label 或 Shape 的背景样式是透明的还是不透明的。"
    BackStyle = UserControl.BackStyle
End Property

Public Property Let BackStyle(ByVal New_BackStyle As Integer)
    UserControl.BackStyle() = New_BackStyle
    PropertyChanged "BackStyle"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,BackColor
Public Property Get BackColor() As OLE_COLOR
Attribute BackColor.VB_Description = "返回/设置对象中文本和图形的背景色。"
    BackColor = UserControl.BackColor
End Property

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
    UserControl.BackColor() = New_BackColor
    PropertyChanged "BackColor"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,BorderStyle
Public Property Get BorderStyle() As Integer
Attribute BorderStyle.VB_Description = "返回/设置对象的边框样式。"
    BorderStyle = UserControl.BorderStyle
End Property

Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
    UserControl.BorderStyle() = New_BorderStyle
    PropertyChanged "BorderStyle"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtMsg,txtMsg,-1,Text
Public Property Get Text() As String
Attribute Text.VB_Description = "返回/设置控件中包含的文本。"
    Text = txtMsg.Text
End Property

Public Property Let Text(ByVal New_Text As String)
    txtMsg.Text() = New_Text
    PropertyChanged "Text"
End Property
'
''注意!不要删除或修改下列被注释的行!
''MappingInfo=cmdSend,cmdSend,-1,Value
'Public Property Get Value() As Boolean
'    Value = cmdSend.Value
'End Property
'
'Public Property Let Value(ByVal New_Value As Boolean)
'    cmdSend.Value() = New_Value
'    PropertyChanged "Value"
'End Property

Private Sub UserControl_Show()
    RaiseEvent Show
End Sub

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,Settings
Public Property Get Settings() As String
Attribute Settings.VB_Description = "设置/返回波特率、奇偶校验、数据位和停止位参数。"
Attribute Settings.VB_ProcData.VB_Invoke_Property = "PropertyPageCom"
    Settings = MSComm1.Settings
End Property

Public Property Let Settings(ByVal New_Settings As String)
    MSComm1.Settings() = New_Settings
    PropertyChanged "Settings"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,Output
'Public Property Get Output() As Variant
'    Output = MSComm1.Output
'End Property

Public Property Let Output(ByVal New_Output As Variant)
'    If Ambient.UserMode = False Then
    MSComm1.Output() = New_Output
    PropertyChanged "Output"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,OutBufferSize
Public Property Get OutBufferSize() As Integer
Attribute OutBufferSize.VB_Description = "设置/返回传输缓冲区中的字符数。"
    OutBufferSize = MSComm1.OutBufferSize
End Property

Public Property Let OutBufferSize(ByVal New_OutBufferSize As Integer)
    MSComm1.OutBufferSize() = New_OutBufferSize
    PropertyChanged "OutBufferSize"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,SThreshold
Public Property Get SThreshold() As Integer
Attribute SThreshold.VB_Description = "设置/返回传输中所能允许的最小字符数。"
    SThreshold = MSComm1.SThreshold
End Property

Public Property Let SThreshold(ByVal New_SThreshold As Integer)
    MSComm1.SThreshold() = New_SThreshold
    PropertyChanged "SThreshold"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,Appearance
Public Property Get Appearance() As Integer
Attribute Appearance.VB_Description = "返回/设置一个对象在运行时是否以 3D 效果显示。"
    Appearance = UserControl.Appearance
End Property

Public Property Let Appearance(ByVal New_Appearance As Integer)
    UserControl.Appearance() = New_Appearance
    PropertyChanged "Appearance"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,DTREnable
Public Property Get DTREnable() As Boolean
Attribute DTREnable.VB_Description = "决定在通讯过程中是否使 Data Terminal Ready 线有效。"
    DTREnable = MSComm1.DTREnable
End Property

Public Property Let DTREnable(ByVal New_DTREnable As Boolean)
    MSComm1.DTREnable() = New_DTREnable
    PropertyChanged "DTREnable"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,EOFEnable
Public Property Get EOFEnable() As Boolean
Attribute EOFEnable.VB_Description = "设置/返回是否搜索 EOF 字符。"
    EOFEnable = MSComm1.EOFEnable
End Property

Public Property Let EOFEnable(ByVal New_EOFEnable As Boolean)
    MSComm1.EOFEnable() = New_EOFEnable
    PropertyChanged "EOFEnable"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,Handshaking
Public Property Get Handshaking() As HandshakeConstants
Attribute Handshaking.VB_Description = "设置/返回软件的握手协议。"
    Handshaking = MSComm1.Handshaking
End Property

Public Property Let Handshaking(ByVal New_Handshaking As HandshakeConstants)
    MSComm1.Handshaking() = New_Handshaking
    PropertyChanged "Handshaking"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,hWnd
Public Property Get hWnd() As Long
Attribute hWnd.VB_Description = "返回一个句柄到(from Microsoft Windows)一个对象的窗口。"
    hWnd = UserControl.hWnd
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtMsg,txtMsg,-1,IMEMode
Public Property Get IMEMode() As Integer
Attribute IMEMode.VB_Description = "返回/设置输入方法编辑器的当前操作模式。"
    IMEMode = txtMsg.IMEMode
End Property

Public Property Let IMEMode(ByVal New_IMEMode As Integer)
    txtMsg.IMEMode() = New_IMEMode
    PropertyChanged "IMEMode"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,InBufferCount
Public Property Get InBufferCount() As Integer
Attribute InBufferCount.VB_Description = "返回接收缓冲区中等待的字符数。"
    InBufferCount = MSComm1.InBufferCount
End Property

Public Property Let InBufferCount(ByVal New_InBufferCount As Integer)
    MSComm1.InBufferCount() = New_InBufferCount
    PropertyChanged "InBufferCount"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,InBufferSize
Public Property Get InBufferSize() As Integer
Attribute InBufferSize.VB_Description = "设置/返回接受缓冲区的大小,以字节数为单位。"
    InBufferSize = MSComm1.InBufferSize
End Property

Public Property Let InBufferSize(ByVal New_InBufferSize As Integer)
    MSComm1.InBufferSize() = New_InBufferSize
    PropertyChanged "InBufferSize"
End Property



'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,InputLen
Public Property Get InputLen() As Integer
Attribute InputLen.VB_Description = "设置/返回 Input 属性从接收缓冲区中读出的字符数。"
    InputLen = MSComm1.InputLen
End Property

Public Property Let InputLen(ByVal New_InputLen As Integer)
    MSComm1.InputLen() = New_InputLen
    PropertyChanged "InputLen"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,InputMode
Public Property Get InputMode() As InputModeConstants
Attribute InputMode.VB_Description = "设置/返回 Input 属性检索的数据类型"
    InputMode = MSComm1.InputMode
End Property

Public Property Let InputMode(ByVal New_InputMode As InputModeConstants)
    MSComm1.InputMode() = New_InputMode
    PropertyChanged "InputMode"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=UserControl,UserControl,-1,Refresh
Public Sub Refresh()
Attribute Refresh.VB_Description = "强制完全重画一个对象。"
    UserControl.Refresh
End Sub

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,RThreshold
Public Property Get RThreshold() As Integer
Attribute RThreshold.VB_Description = "设置/返回要接受的字符数。"
    RThreshold = MSComm1.RThreshold
End Property

Public Property Let RThreshold(ByVal New_RThreshold As Integer)
    MSComm1.RThreshold() = New_RThreshold
    PropertyChanged "RThreshold"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,RTSEnable
Public Property Get RTSEnable() As Boolean
Attribute RTSEnable.VB_Description = "决定是否能使 Request To Send 行有效。"
    RTSEnable = MSComm1.RTSEnable
End Property

Public Property Let RTSEnable(ByVal New_RTSEnable As Boolean)
    MSComm1.RTSEnable() = New_RTSEnable
    PropertyChanged "RTSEnable"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=MSComm1,MSComm1,-1,NullDiscard
Public Property Get NullDiscard() As Boolean
Attribute NullDiscard.VB_Description = "决定是否将空字符串从端口传送到接收缓冲区。"
    NullDiscard = MSComm1.NullDiscard
End Property

Public Property Let NullDiscard(ByVal New_NullDiscard As Boolean)
    MSComm1.NullDiscard() = New_NullDiscard
    PropertyChanged "NullDiscard"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtDestPhoneNum,txtDestPhoneNum,-1,Text
Public Property Get DestPhoneNumber() As String
Attribute DestPhoneNumber.VB_Description = "返回/设置控件中包含的文本。"
    DestPhoneNumber = txtDestPhoneNum.Text
End Property

Public Property Let DestPhoneNumber(ByVal New_DestPhoneNumber As String)
    txtDestPhoneNum.Text() = New_DestPhoneNumber
    PropertyChanged "DestPhoneNumber"
End Property

'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtMsg,txtMsg,-1,Text
Public Property Get MsgText() As String
Attribute MsgText.VB_Description = "返回/设置控件中包含的文本。"
    MsgText = txtMsg.Text
End Property

Public Property Let MsgText(ByVal New_MsgText As String)
    txtMsg.Text() = New_MsgText
    PropertyChanged "MsgText"
End Property

'注意!不要删除或修改下列被注释的行!
'MemberInfo=13,0,0,+8613800769500
Public Property Get SMSC() As String
Attribute SMSC.VB_Description = "短信中心号码"
Attribute SMSC.VB_ProcData.VB_Invoke_Property = "PropertyPageSMS"
    SMSC = m_SMSC
End Property

Public Property Let SMSC(ByVal New_SMSC As String)
    m_SMSC = New_SMSC
    PropertyChanged "SMSC"
End Property


'注意!不要删除或修改下列被注释的行!
'MappingInfo=txtMsg,txtMsg,-1,MultiLine
Public Property Get MultiLine() As Boolean
Attribute MultiLine.VB_Description = "返回/设置一个值,决定一个控件是否可以接受多行文本。"
    MultiLine = txtMsg.MultiLine
End Property


Private Function CommOpen() As Boolean
On Error GoTo ErrHandle
'    SmsInit 1, "9600,n,8,1"
    
        With MSComm1
            If .PortOpen = True Then
                CommOpen = True
                Exit Function
            End If
            
'            .CommPort = 1
            .RThreshold = 1
            .SThreshold = 0
            .Handshaking = comNone
            
            
'            .Settings = "9600" & ",N,8,1"
            .PortOpen = True
'            CmbPortName.Enabled = False
        End With
        
    


 
    If MSComm1.PortOpen Then

        MSComm1.Output = "ATE0" + Chr(13) + Chr(10)
        MSComm1.RThreshold = 1
        MSComm1.Output = "AT+CMGF=1" + Chr(13) + Chr(10)
'        MSComm1.Output = "AT+CSMP=4,167,0,8" + Chr(13) + Chr(10)
'上边两行语句作为联机是初始化用的命令
    End If
    CommOpen = True
    Exit Function
ErrHandle:
   RaiseEvent ValidResult(Err.Number, Err.Description)
   CommOpen = False
End Function
''注意!不要删除或修改下列被注释的行!
''MappingInfo=MSComm1,MSComm1,-1,Input
'Public Property Get Input() as Variant
'    If Ambient.UserMode = False Then
'    Input = MSComm1.Input
'End Property
'
'Public Property Let Input(ByVal New_Input as Variant)
'    MSComm1.Input() = New_Input
'    PropertyChanged "Input"
'End Property

⌨️ 快捷键说明

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