I am reading an sms from a phone. I am trying to store the sms message - it is supposed to be stored in PDU_count(PDU) where PDU = 3. It works no problem, however sometimes it says that the index is outside of the array. If i stop and restart, then run again (i.e reading same text again) it works.Is there a way to check whether the position exists or something and if it doesnt run the code again or something?
Code:incoming_messages = smsPort.ReadExisting() r_count = incoming_messages.IndexOf("+CMS ERROR: 321") 'conditional here If r_count < 0 Then 'incoming_messages = incoming_messages.Replace(vbCrLf, "") TxtEventLog.Text = incoming_messages & vbCrLf PDU_count = incoming_messages.Split(vbCrLf) TxtEventLog.Text += vbCrLf & "PDU seperated: " & PDU_count(0) TxtEventLog.Text += vbCrLf & "PDU seperated: " & PDU_count(1) TxtEventLog.Text += vbCrLf & "PDU seperated: " & PDU_count(2) TxtEventLog.Text += vbCrLf & "PDU seperated: " & PDU_count(PDU)




Reply With Quote