4 Replies - 10080 Views - Last Post: 09 December 2012 - 09:33 AM Rate Topic: -----

#1 gjacob08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-October 12

Sending SMS using VB.net

Posted 08 December 2012 - 04:39 AM

Hi guys! Badly need your help. I'm working on a project in VB.net that will enable my application from sending SMS. I already have the code but I'm getting an error which is "The port 'COM15' does not exist." I've tried to search this error in google but it didn't help at all. Thanks in advance for your help.

Here is my code:

Imports System.IO.Ports

Public Class Form1
Dim SerialPort1 As New System.IO.Ports.SerialPort()

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SerialPort1.PortName = "COM15"
SerialPort1.BaudRate = 9600
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.DataBits = 8
SerialPort1.Handshake = Handshake.RequestToSend
SerialPort1.DtrEnable = True
SerialPort1.RtsEnable = True
SerialPort1.NewLine = vbCrLf
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim message As String
message = RichTextBox1.Text
SerialPort1.Open()

If SerialPort1.IsOpen() Then
SerialPort1.Write("AT" & vbCrLf)
SerialPort1.Write("AT+CMGF=1" & vbCrLf)
SerialPort1.Write("AT+CMGS=" & Chr(34) & TextBox1.Text & Chr(34) & vbCrLf)
SerialPort1.Write(message & Chr(26))
MsgBox("Sent")
Else
MsgBox("Port not available")

End If

End Sub

End Class




Is This A Good Question/Topic? 0
  • +

Replies To: Sending SMS using VB.net

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5540
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Sending SMS using VB.net

Posted 08 December 2012 - 06:58 AM

Its not a code error. Your PC doesn't have a serial port named "COM15"

Look at Device Manager and see what ports you do have.

Do you have an SMS capable modem attached to your PC? What model?
Was This Post Helpful? 1
  • +
  • -

#3 gjacob08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-October 12

Re: Sending SMS using VB.net

Posted 08 December 2012 - 07:43 PM

Thank you so much for your reply. I've connected my Nokia 2700C using a USB cable to my computer and I went to the device manager, then portable devices to check on the port name but its not giving me a port name that starts with COM, it only shows the port number which is 0001 and VB is not accepting that. Please tell me if I'm doing this right. Thanks in advance.
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5540
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Sending SMS using VB.net

Posted 09 December 2012 - 08:03 AM

You obviously don't know what a COM port is, how it is different from a USB port etc. etc.

The code you provided is obviously copy/paste from something you found on the internet and you don't understand that its for a serial port device.

I'm sorry. It is beyond the scope of a thread to teach you all about computer hardware, as well as programming. You might as well be saying "I want to learn medicine. Let's start by performing a simply appendectomy. Tell me what I need to do."

For now, just concentrate on learning the basics of computers and the basics of your chosen programming language through a few "Teach yourself VB.NET in 30 days" type books. Don't try to architect and build programs from scratch yet.
Was This Post Helpful? 0
  • +
  • -

#5 gjacob08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-October 12

Re: Sending SMS using VB.net

Posted 09 December 2012 - 09:33 AM

Thank you for your advice. I understand your point sir. To be honest, I'm still a newbie in programming and I'm trying to do advance studying. I really need to do a lot of practice to get better. Thanks for your help anyway.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1