2013-03-19 47 views
0

任何人都可以幫助我如何使用通過pcsuite連接的諾基亞移動在vb 6.0中發送短信。Vb 6.0發送短信諾基亞PC套件

下面是我使用的代碼。 iam在調用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 
+0

對不起史蒂夫錯誤我標記vb.net。我編輯我的帖子,並把vb編碼我用過的。你能幫我整理一下嗎? – Yuvaraj 2013-03-20 08:47:02

回答

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 
+0

是的,但我得到一個錯誤在呼叫pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY,pIGSMSubmit)。對象變量或未設置塊 – Yuvaraj 2013-03-20 08:40:52

+0

@Yuvaraj - 請參閱我的編輯答案 – 2013-03-20 11:10:43

+0

非常感謝您的時間馬特,上述問題解決了,但我得到一個新的錯誤手機未連接 – Yuvaraj 2013-03-21 07:41:54