Sending SMS via USB GSM Modem - vb.net

I am trying to develop a module to send SMS from my application. The problem is that when I send an AT Command to a connected cell phone, my app stops responding. I'm using a Nokia 6720C and I have installed Pc Suite. It also appears in the Com Ports.
My code is below. What am I doing wrong?
Imports System
Imports System.IO.Ports
Imports System.Threading
Imports System.ComponentModel
Public Class Form1
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
With SerialPort1
.PortName = "COM14"
.DataBits = 8
.Parity = IO.Ports.Parity.None
.StopBits = StopBits.One
End With
SerialPort1.Open()
SerialPort1.Write("AT" & vbCr)
SerialPort1.Close()
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
'compares the ID of the creating Thread to the ID of the calling Thread
If Me.TxtResponse.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.TxtResponse.Text &= [text]
End If
End Sub

Well, at the end of the AT command you must add Chr(13) and Chr(10), you used Chr(13) only (which is "vbCr"), try replacing it with vbCrLf (Carriage-Return "Chr(13)" and Line Feed "Chr(10)"). I think this is the problem (the command string is not complete).
If the problem still resides, try the following to test your work:
Try using your VB.NET code to communicate with a GSM modem (not your phone). If it works fine, then maybe the phone does not accept AT commands.
Try using a terminal program to send the AT command to the phone. The terminal program can be like "Hyper Terminal" or "Maestro Smart Terminal" (you can search for it on google).
I hope this was helpful, good luck.

Related

Windows Media Player VB.net

I have a WMP in my vb.net project and I wanted to load the next media automatically after the first is finnished I did some research on googel and found the simple to understand code as per below.
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
AxWindowsMediaPlayer1.URL = ("Test2.mp4")
MessageBox.Show("Playing End")
End If
End Sub
I however cant get it to automatically play the next (Test2.mp4) unless I have the messagebox pop-up. I discovered this purely by accident. However I dont want the Messagebox to pop-up everytime a new Mp4 file is ready to be played. Dose anybody know what is going on here and how I can fix this?
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oTask01 As Threading.Thread
oTask01 = New Threading.Thread(AddressOf oStarting01)
oTask01.Start()
Dim omessagebox As MessageBox = Nothing
omessagebox.Show("Playing End", "", MessageBoxButtons.OK)
oTask01.Abort()
End Sub
Private Function oStarting01() As Byte
While True
System.Windows.Forms.SendKeys.SendWait(vbCr)
End While
Return 0
End Function
End Class
Hi, try with this code. It works. Diving more deeply in Windows system and subsystems is not an easy task, not at least for me. I hope you get what you were looking for for your software. Thank you very much. Happy codding!. :)
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As
System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent)
Handles AxWindowsMediaPlayer1.PlayStateChange
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
AxWindowsMediaPlayer1.URL = ("Test2.mp4")
'MessageBox.Show("Playing End") 'This line was commented because is not neccesary in this fragment of code
End If
End Sub
Hi, if I have understood well to you, you wanted to supress the message box. It is got doing a comment's line with "'". I hope you like it and continue enjoying with computers and software. Thank you very much and happy codding. :)

Brother Printer Visual Basic 10

Hello everyone and thank you for being such great and helpful community. I am currently working on Visual Basic App (using 10 express version) to print labels by using Brother Printer QL-500. For some reason samples provided by Brother don't work.... any of them and worst part there is no Errors any kind.... now Brother P-Touch Editor 5.1 works and prints fine. I am using b-PAC3 Client Component(64 Bit), running on Windows 7 64 bit. I know some people suggested to target x86 and I did that with no luck its a same thing nothing is happening please see Brother Code I am using below. Thanks!
b-PAC 3.0 Component Sample (Badge)
'
' (C)Copyright Brother Industries, Ltd. 2009
'
'*******************************************************************
Option Explicit On
Public Class Badge
Const sPath = "C:\Program Files\Brother bPAC3 SDK\Templates\Badge.lbx"
'********************************************************
' Open and Print a spcified file.
'********************************************************
Public Sub DoPrint()
Dim bRet As Boolean
Dim ObjDoc As bpac.Document
ObjDoc = CreateObject("bpac.Document")
'Open lbx file
bRet = ObjDoc.Open(sPath)
If (bRet <> False) Then
ObjDoc.GetObject("objName").Text = txtName.Text
ObjDoc.GetObject("objCompany").Text = txtCompany.Text
'objDoc.SetMediaByName(objDoc.Printer.GetMediaName, True)
ObjDoc.StartPrint("", bpac.PrintOptionConstants.bpoDefault)
ObjDoc.PrintOut(1, bpac.PrintOptionConstants.bpoDefault)
ObjDoc.EndPrint()
ObjDoc.Close()
End If
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
DoPrint()
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
End Class
After trying to contact Brother technical for 2 weeks resolved nothing still waiting for their response but everything is working now... Not this Badge code but my program if anyone has same issue try installing b-PAC3 Client Component non 64 as well and re-install brother drivers somehow this fixes the issue still wonder what is the problem would be nice to know to avoid it on other systems.

Vb.Net compiling error

When I try and run my program in debug i keep receiving an error BC30456 it reads as follows:
Severity Code Description Project File Line Suppression State
Error BC30456 'Form1' is not a member of 'serialtest2'. serialtest2 C:\Users\Rhans\Desktop\VB6 Programs\Ethernet Socket\serialtest2\My Project\Application.Designer.vb 35 Active
I am looking to monitor a serial port that has a mettler toledo scale hooked to it and I am trying to display a continuous weight on the form...
Any help would be greatly appreciated.
The code is as follows:
Imports System.IO.Ports
Imports System.IO.Ports.SerialPort
Public Class SerialCommunication
Private WithEvents Port As New SerialPort
Private Sub SerialCommunication_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With Port
.PortName = "COM5"
.RtsEnable = True
.BaudRate = 9600
.Open()
End With
End Sub
Private Sub port_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Port.DataReceived
Dim buffer As String = Port.ReadExisting()
txtDisplay.Text = buffer
End Sub
Your SerialCommunication Class replaces Form1 by the looks of it.
Go to Project > Properties then select Startup Form: Serial Communication or change the name of your class to "Form1" instead of "SerialCommunication"
I had the same problem and my solution came from Web.config. I had removed the default language from compilation node. When i put it back it worked fine.
<compilation debug="true" defaultLanguage="vb" targetFramework="4.5.2">

How to play 2 different sounds at the same time?(Visual basic)

I have a problem about a game. I want to play a background sound and another sound when you click a button. When this happens, the background sound stops and the 2nd sound starts. When the 2nd sound finishes, no sound will be played.
You can see my code below:
Imports System.Media.SoundPlayer
Public Class GamePlaying
Dim mainmenusndplayer As New System.Media.SoundPlayer
Private Sub GamePlaying_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
MainMenu.Show()
mainmenusndplayer.Stop()
End Sub
Private Sub btn_Fire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Fire.Click
btn_Fire.Enabled = False
Dim shotsound As New System.Media.SoundPlayer
shotsound.Stream = My.Resources.TankShoot
shotsound.Play()
End Sub
Private Sub GamePlaying_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mainmenusndplayer.Stream = My.Resources.WoT_Roll_Out
mainmenusndplayer.Load()
mainmenusndplayer.PlayLooping()
End Sub
End Class
I had been struggling with the same issue.....
The short answer is you can't. The system will only permit one channel to the sound interface within any given process. As such, when you start a new sound, the previous one terminates.
There are a number of work-arounds which mostly use either Direct-X or Media-Player. However, I found neither of those solutions to be either easy or robust in that you are depending on the users machine to have the right things installed.
However, I found a quick and simple solution to the problem.
I added a special "hook" to my application so that when I run it with an appropriate command line argument, all it does is play a particular sound and quit. I then use the process object to start another instance of the application with the appropriate argument.. and hey presto.. multiple sounds.
If your application is configured to automatically be be a single instance, you need to disable that and replace it with a little code to detect another instance and quit.
Another alternative is to add a small exe to your application package that simply does the sound part.
I know it does not sound very "pure", but really, all you are doing is starting a process to play a sound in the background. It doesn't really matter if that process is a windows native function or one of your own making.
you can use winmm.dll with mciSendString :
Imports System.Text
Imports System.Runtime.InteropServices
<DllImport("winmm.dll")>
Private Shared Function mciSendString(ByVal command As String, ByVal buffer As
StringBuilder, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer
End Function
Private Sub MyForm_Click(sender As Object, e As EventArgs) Handles Me.Click
mciSendString("open " & Chr(34) & "C:\myFile1.wav" & Chr(34) " type waveaudio alias Sound1" & internalName, Nothing, 0, IntPtr.Zero)
mciSendString("open " & Chr(34) & "C:\myFile2.wav" & Chr(34) " type waveaudio alias Sound2" & internalName, Nothing, 0, IntPtr.Zero)
mciSendString("play Sound1", Nothing, 0, Me.Handle.ToInt64())
mciSendString("play Sound2", Nothing, 0, Me.Handle.ToInt64())
mciSendString("setaudio Sound1 volume to 1000", Nothing, 0, Me.Handle.ToInt64())
mciSendString("setaudio Sound2 volume to 1000", Nothing, 0, Me.Handle.ToInt64())
End Sub
and to stop the sounds you have to :
mciSendString("close Name1", Nothing, 0, Me.Handle.ToInt64())
mciSendString("close Name2", Nothing, 0, Me.Handle.ToInt64())
Download winmm.dll at https://www.dll-files.com/winmm.dll.html

Using Nokia AT command in VB 2010

I am a beginner in learning AT commands and windows programming.
I prepared a code just to read the Serial no of a Nokia phone in VB 2010 as
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.Open()
SerialPort1.WriteLine("AT")
SerialPort1.WriteLine("AT+CNUM")
TextBox1.Text = SerialPort1.ReadLine()
SerialPort1.Close()
End Sub
End Class
Unfortunately, it is not working, no error message.
Port I selected is COM which I verified through device manager. Baud rate set as 9600.
If anybody can help, Please.......
Thanks
0) open read before write,
try switch:
SerialPort1.Open()
TextBox1.Text = SerialPort1.ReadLine()
SerialPort1.WriteLine("AT")
SerialPort1.WriteLine("AT+CNUM")
SerialPort1.Close()
1) send \r (\r\n) -- end of string
2) use command with view resultats:
call (ATD<number>);
busy (ATH);
response call (ATA) -- for view this 2 commands to call from phone to modem;
other (blink/switch off radio/play tone)
disclaimer:
VB don't know, i'm using python on Linux;
sorry for my dirty english.