Click here to Skip to main content
15,888,113 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: save images as .gif Pin
Chris Quinn12-May-14 20:56
Chris Quinn12-May-14 20:56 
GeneralRe: save images as .gif Pin
khei-chan00712-May-14 21:25
khei-chan00712-May-14 21:25 
GeneralSaving Image as Gif Pin
I. Bandaranayake13-May-14 1:49
I. Bandaranayake13-May-14 1:49 
AnswerRe: save images as .gif Pin
Richard MacCutchan12-May-14 22:47
mveRichard MacCutchan12-May-14 22:47 
QuestionMapWinGis project in Visual Basic.NET Pin
Member 1081056711-May-14 7:32
Member 1081056711-May-14 7:32 
QuestionVB CODE TO RECEIVE SMS THROUGH GSM MODEM Pin
elly ianto10-May-14 2:34
elly ianto10-May-14 2:34 
AnswerRe: VB CODE TO RECEIVE SMS THROUGH GSM MODEM PinPopular
Dave Kreskowiak10-May-14 3:38
mveDave Kreskowiak10-May-14 3:38 
GeneralRe: VB CODE TO RECEIVE SMS THROUGH GSM MODEM Pin
elly ianto12-May-14 3:24
elly ianto12-May-14 3:24 
'class code
Imports System.IO.Ports
Imports System.Threading

Public Class SMSCOMMS
Private WithEvents SMSPort As SerialPort

Private SMSThread As Thread
Private ReadThread As Thread
Shared _Continue As Boolean = False
Shared _ContSMS As Boolean = False
Private _Wait As Boolean = False
Shared _ReadPort As Boolean = False
Public Event Sending(ByVal Done As Boolean)
Public Event DataReceived(ByVal Message As String)

Public Sub New(ByRef COMMPORT As String)
SMSPort = New SerialPort
With SMSPort
.PortName = COMMPORT
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With

ReadThread = New Thread(AddressOf ReadPort)
End Sub

Public Sub SendSMS(ByVal CellNumber As String, ByVal SMSMessage As String)
Dim MyMessage As String = Nothing
If SMSMessage.Length <= 160 Then
MyMessage = SMSMessage
Else
MyMessage = Mid(SMSMessage, 1, 160)
End If
If IsOpen = True Then
SMSPort.WriteLine("AT")
Thread.Sleep(1000)
SMSPort.WriteLine("AT+CMGF=1" & vbCrLf) 'setting modem for sms mode
Thread.Sleep(1000)
'SMSPort.WriteLine("AT+CSCA=""+254722500059" & vbCrLf) 'setting the message service center number
SMSPort.WriteLine("AT+CMGS=""" & CellNumber & """" & vbCrLf)
Thread.Sleep(1000)
'SMSPort.WriteLine("AT+CMGS=" & CellNumber & vbCrLf)
_ContSMS = False
SMSPort.WriteLine(MyMessage & vbCrLf & Chr(26))
Thread.Sleep(1000)
_Continue = False
RaiseEvent Sending(False)
'MessageBox.Show("Successfully sent")
End If
End Sub

Private Sub ReadPort()
Dim SerialIn As String = Nothing
Dim RXBuffer(SMSPort.ReadBufferSize) As Byte
Dim SMSMessage As String = Nothing
Dim Strpos As Integer = 0
Dim TmpStr As String = Nothing
Try

Catch ex As Exception


While SMSPort.IsOpen = True
If (SMSPort.BytesToRead <> 0) And (
SMSPort.IsOpen = True) Then
While SMSPort.BytesToRead <> 0
SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize)
SerialIn =
SerialIn & System.Text.Encoding.ASCII.GetString(
RXBuffer)
If SerialIn.Contains(">") = True Then
_ContSMS = True
End If
If SerialIn.Contains("+CMGS:") = True Then
_Continue = True
RaiseEvent Sending(True)
_Wait = False
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
End While
RaiseEvent DataReceived(SerialIn)
SerialIn = String.Empty
ReDim RXBuffer(SMSPort.ReadBufferSize)
End If
End While
End Try
End Sub

Public ReadOnly Property IsOpen() As Boolean
Get
If SMSPort.IsOpen = True Then
IsOpen = True
Else
IsOpen = False
End If
End Get
End Property

Public Sub Open()
If IsOpen = False Then
SMSPort.Open()
ReadThread.Start()
End If
End Sub

Public Sub Close()
If IsOpen = True Then
SMSPort.Close()
End If
End Sub

End Class

'window form
'Form Code
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.IO.Ports
Imports mordemsms.SMSCOMMS

Public Class Form1

Private Sub sendbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sendbtn.Click
Dim sms As SMSCOMMS
sms = New SMSCOMMS("COM12")
sms.Open()
sms.SendSMS(TextBox1.Text, TextBox2.Text)
sms.Close()
End Sub



End Class


ok. this is the code i have written to receive an sms. i want to add the function to receive a sms on the same modem. i am unable to go on. somebody help please.
Questionentity framework too slow executing even a small query Pin
dilkonika9-May-14 14:11
dilkonika9-May-14 14:11 
AnswerRe: entity framework too slow executing even a small query Pin
Dave Kreskowiak10-May-14 3:43
mveDave Kreskowiak10-May-14 3:43 
GeneralRe: entity framework too slow executing even a small query Pin
dilkonika10-May-14 8:49
dilkonika10-May-14 8:49 
GeneralRe: entity framework too slow executing even a small query Pin
Dave Kreskowiak10-May-14 11:10
mveDave Kreskowiak10-May-14 11:10 
GeneralRe: entity framework too slow executing even a small query Pin
dilkonika11-May-14 5:45
dilkonika11-May-14 5:45 
GeneralRe: entity framework too slow executing even a small query Pin
Dave Kreskowiak11-May-14 5:55
mveDave Kreskowiak11-May-14 5:55 
GeneralRe: entity framework too slow executing even a small query Pin
dilkonika11-May-14 7:17
dilkonika11-May-14 7:17 
QuestionHow to create a file Pin
ShadowsrayChamhell9-May-14 5:45
ShadowsrayChamhell9-May-14 5:45 
AnswerRe: How to create a file Pin
Simon_Whale9-May-14 5:50
Simon_Whale9-May-14 5:50 
GeneralRe: How to create a file Pin
ShadowsrayChamhell9-May-14 6:02
ShadowsrayChamhell9-May-14 6:02 
Question8-puzzle game Pin
Member 108030917-May-14 21:04
Member 108030917-May-14 21:04 
AnswerRe: 8-puzzle game Pin
Chris Quinn7-May-14 21:11
Chris Quinn7-May-14 21:11 
AnswerRe: 8-puzzle game Pin
Mycroft Holmes7-May-14 23:23
professionalMycroft Holmes7-May-14 23:23 
Question8-puzzle game Pin
Member 108030917-May-14 21:01
Member 108030917-May-14 21:01 
QuestionPaste in next available row Pin
David Rubin6-May-14 6:43
David Rubin6-May-14 6:43 
AnswerRe: Paste in next available row Pin
Eddy Vluggen6-May-14 7:25
professionalEddy Vluggen6-May-14 7:25 
GeneralRe: Paste in next available row Pin
David Rubin6-May-14 7:27
David Rubin6-May-14 7:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.