Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Hello,
I am totally new for VB. Can anyone please guide me on the code for VB for serial communication and GSM interfacing.
you can use a SerialPort object soThanx zeyad n horace....
However i am searching for the syntax used for writing such code. I have worked with AT commands. But not getting how to implement it in VB. I am using VB6.
SerialPort1.Write("AT+CSQ\n")
Code Visual Basic - [expand] 1 2 3 4 5 6 7 8 Private Sub Form_Load() MSCom1.CommPort = 4 'comm port no.--------------error----------------- MSCom1.Settings = "9600,n,8,1" MSCom1.RThreshold = 24 'no. of chr to recive MSCom1.InputLen = 0 ' no. of chr on which oncomm event fires MSCom1.PortOpen = True 'open comm port End Sub
Code Visual Basic - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Private Sub Form_Load() --------------------------------error------------------------ Dim strValue As String ' define Buffer value from Modem MSCom1.CommPort = 4 'comm port no. MSCom1.Settings = "9600,n,8,1" MSCom1.RThreshold = 24 'no. of chr to recive MSCom1.InputLen = 0 ' no. of chr on which oncomm event fires MSCom1.PortOpen = True 'open comm port MSComm1.Output = "ATV1Q0" & Chr&(13) 'send AT command to Modem Do DoEvents strValue = strValue & MSComm1.Input ' get input data of Com Port Loop Until InStr(strValue, "OK" & vbCrLf) Text1.Text = strValue MSComm1.PortOpen = False 'Close port End Sub
Thanx zeyad n horace....
However i am searching for the syntax used for writing such code. I have worked with AT commands. But not getting how to implement it in VB. I am using VB6.
Thanx Zeyad,
I chose microsoft comm6 and put phone icon on form. I am not getting what you want to install me. I have no msdn library installed.
you could use the string manipulation methods, e.g. InStr to look for the +i solved the issue, i got the commands. Now dats i am receiving is in the format
+CLIP: "+918554888728",145,"",,"",0. How to extract mobile number from this data in VB6.
I am actually getting whole command and data from modem like this
AT+CLIR=1OKAT+CLIP=1OKRING+CLIP: "+919823596784",145,"",,"",0
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.strings.instr.aspx
Code Visual Basic - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Form_Load() On Error GoTo errx: Dim strValue As String ' define Buffer value from Modem MSComm1.CommPort = 6 'comm port no. MSComm1.Settings = "9600,n,8,1" MSComm1.RThreshold = 24 'no. of chr to recive MSComm1.InputLen = 0 ' no. of chr on which oncomm event fires MSComm1.PortOpen = True 'open comm port Exit Sub errx: MsgBox "error" End Sub Private Sub Command1_Click() 'MSComm1.Output = "AT" + Chr(13) + vbCrLf 'Sleep 1000 'MSComm1.Output = "AT+CMGDA=DEL ALL" + Chr(13) + vbCrLf 'Sleep 1000 'MSComm1.Output = "AT+FCLASS=8" + Chr(13) 'MSComm1.Output = "ATE0" + Chr(13)+ vbCrLf 'Sleep 200 'MSComm1.Output = "ATS0=1" + Chr(13) 'Sleep 200 'MSComm1.Output = "AT+CMGF=1" + Chr(13) '& Chr(10) 'Sleep 500 'MSComm1.Output = "AT+CMGR" + Chr(13) '& Chr(10) 'MSComm1.Output = "AT+CMGS=9860939518" + vbCrLf + Chr(13) 'Sleep 1000 'MSComm1.Output = "Test message---1" + Chr(26) 'Sleep 2000 'MSComm1.Output = "AT+CMGR" + Chr(13) '& Chr(10) MSComm1.Output = "AT+CLIR=1" + Chr(13) Sleep 1000 MSComm1.Output = "AT+CLIP=1" + Chr(13) sleep 1000 Text1.Text = MSComm1.Input End Sub
Sub Main()
Dim Test As String = "AT+CLIR=1OKAT+CLIP=1OKRING+CLIP: ""+919823596784"",145,"""",,"""",0"""
Console.WriteLine("input data {0}", Test)
Dim Pos As Integer
Pos = InStr(Test, """+") + 1
Console.WriteLine("Start of number {0}", Pos)
Dim Number As String = Mid(Test, Pos)
Console.WriteLine("Number {0}", Number)
Pos = InStr(Number, """") - 1
Number = Mid(Number, 1, Pos)
Console.WriteLine("Number {0}", Number)
End Sub
input data AT+CLIR=1OKAT+CLIP=1OKRING+CLIP: "+919823596784",145,"",,"",0"
Start of number 35
Number +919823596784",145,"",,"",0"
Number +919823596784
Press any key to continue . . .
Number = Mid(Test, InStr(Test, """+") + 1, InStr(InStr(Test, """+") + 1, Test, """") - 1 - InStr(Test, """+"))
Console.WriteLine("Number {0}", Number)
Here is a link for reference for Gsm AT commandsThanx zeyad,
I have succeeded in sending and receiving message to GSM module. However can you please tell me what is the AT command to read SIM number when call is received and VB6 coding logic to get exactly only SIM number and get rid of rest of the data.
hey zeyad ,
i solved the issue, i got the commands. Now dats i am receiving is in the format
+CLIP: "+918554888728",145,"",,"",0. How to extract mobile number from this data in VB6.
I am actually getting whole command and data from modem like this
AT+CLIR=1OKAT+CLIP=1OKRING+CLIP: "+919823596784",145,"",,"",0
strange, if the code sometimes extracts the correct data and sometimes not
post some sample dataRING+CLIP: "+919823596784",145,"",,"",0"
Dim str As String
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
On Error GoTo errx:
Dim strValue As String ' define Buffer value from Modem
MSComm1.CommPort = 6 'comm port no.
MSComm1.Settings = "9600,n,8,1"
MSComm1.RThreshold = 47 'no. of chr to recive
MSComm1.InputLen = 0 ' no. of chr on which oncomm event fires
MSComm1.PortOpen = True 'open comm port
Exit Sub
errx:
MsgBox "error"
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
'Events
Case comEvReceive
'Case comEvRing
Text1.Text = MSComm1.Input
str = Text1.Text
Text2.Text = InStr(str, "+91")
Case Else
End Select
End Sub
Text2.Text = InStr(str, "+91")
InStr(str, "RING+CLIP:")