Vb 6.0发送短信诺基亚PC套件

时间:2013-03-19 08:52:54

标签: vb6 sms nokia

任何人都可以帮助我使用通过pcsuite连接的诺基亚手机在vb 6.0中发送短信。

以下是我正在使用的代码。我在调用pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY,pIGSMSubmit)中收到错误。它是说对象变量或块变量未设置

Private lngEventCounter As Long
Private pFolderList() As NokiaCLMessaging.ShortMsgFolderItem
Private pSMSAdapter As NokiaCLMessaging.ShortMsgAdapter
Private pIGSMSubmit As NokiaCLMessaging.IGSMSubmit
Private pSMSMessageItem As NokiaCLMessaging.ShortMessageItem
Private pIGSMDeliver As NokiaCLMessaging.IGSMDeliver
Private pIMemory As NokiaCLMessaging.IMemory
Private pFreeIdxs As Variant
Private pFreeSimIdxs As Variant
Private pCurrentFolderIndex As Byte
Private pMsgPart1 As String
Private pMsgPart2 As String
Private Const CODING_SCHEME_UNICODE = 8
Private Const CODING_SCHEME_TEXT = 0
Private Const SMS_TEXT_MAX_SIZE = 160
Private Const SMS_UNICODE_MAX_SIZE = 70
Private Const SMS_CONCATENATED_TEXT_MAX_SIZE = 153
Private Const SMS_CONCATENATED_UNICODE_MAX_SIZE = 67
Private parameterEntry As NokiaCLMessaging.IGSMParameters
Private Sub SendConcatenatedMessage()

On Error GoTo ErrorTrap

    Dim smsEntry As NokiaCLMessaging.ShortMessageItem
    Set smsEntry = New NokiaCLMessaging.ShortMessageItem

    Dim headerArray(0 To 5) As Byte

    smsEntry.Type = SHORTMESSAGE_TYPE_GSM_SUBMIT
    Set pIGSMSubmit = smsEntry.TypeProperties

    pIGSMSubmit.message = pMsgPart1
    pIGSMSubmit.DestinationAddress = txtDestinationNumber.Text
    pIGSMSubmit.ServiceCenterAddress = "+919894051914"
    pIGSMSubmit.ProtocolID = 0
    pIGSMSubmit.DataCodingScheme = 0
    pIGSMSubmit.ValidityPeriodRelative = 255

    headerArray(0) = 5 'header lenght
    headerArray(1) = 0 'concatenated sms
    headerArray(2) = 3 'length of information element A
    headerArray(3) = 50 'reference number
    headerArray(4) = 2 '2 messages
    headerArray(5) = 1 'sequence number of sms

    pIGSMSubmit.UserDataHeader = headerArray

    Call pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY, pIGSMSubmit)

    pIGSMSubmit.message = pMsgPart2
    pIGSMSubmit.DestinationAddress = txtDestinationNumber.Text
    pIGSMSubmit.ServiceCenterAddress = "+919894051914"
    pIGSMSubmit.ProtocolID = 0
    pIGSMSubmit.DataCodingScheme = 0
    pIGSMSubmit.ValidityPeriodRelative = 255

    headerArray(0) = 5 'header lenght
    headerArray(1) = 0 'concatenated sms
    headerArray(2) = 3 'length of information element A
    headerArray(3) = 51 'reference number
    headerArray(4) = 2 '2 messages
    headerArray(5) = 2 'sequence number of sms

    pIGSMSubmit.UserDataHeader = headerArray

    Call pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY, pIGSMSubmit)
    MsgBox ("Concatenated MEssage sent")

Exit Sub

ErrorTrap:
    MsgBox Err.Description, vbInformation, "Error Concatenate Message"
End Sub

Private Sub Form_Load()

End Sub

1 个答案:

答案 0 :(得分:1)

这个论坛帖子谈到了这个确切的话题 - 在你提出这个问题之前你是否尝试过谷歌搜索?

http://www.developer.nokia.com/Community/Discussion/showthread.php?159438-Send-SMS-in-Visual-Basic-using-Mobile-Phone-as-Modem

现在你已经添加了一些代码,看起来你还没有初始化对象 - 因此错误。试试看吧:

Set pSMSAdapter = New NokiaCLMessaging.ShortMsgAdapter