SEND SMS from samsung galaxy win celphone using vb.net - vb.net-2010

How to send sms from your cellphone to any number using vb.net? I have searched over the internet including youtube but it seems that i could not find or cant figure out where to start. My CP cant event detected in the "phone and modem" in windows...

I have a perfect way to send SMS in visual basic, using AT-commands.
AT-commands:are instructed through which you can send and receive SMS messages, make calls from cell phone, and this is an example to Send a message:
Firstly:
Write this code in the top:
Imports System.IO.Ports
Imports System.IO
Secondly:
Write this code in the public class of form:
Dim SerialPort As New System.IO.Ports.SerialPort()
Dim CR As String
Thirdly:
Create a textBox(TextmsgTextBox) to write the text message, and TextBox2(MobileNumberTextBox) to enter the mobile number, and Button(SendBUT) to Send message.
And write this code in the button click event.
If SerialPort.IsOpen Then
SerialPort.Close()
End If
SerialPort.PortName = COM4
SerialPort.BaudRate = 9600
SerialPort.Parity = Parity.None
SerialPort.StopBits = StopBits.One
SerialPort.DataBits = 8
SerialPort.Handshake = Handshake.RequestToSend
SerialPort.DtrEnable = True
SerialPort.RtsEnable = True
SerialPort.NewLine = vbCrLf
Dim message As String
message = MsgRichTextBox.Text
SerialPort.Open()
If SerialPort.IsOpen() Then
SerialPort.Write("AT" & vbCrLf)
SerialPort.Write("AT+CMGF=1" & vbCrLf)
SerialPort.Write("AT+CMGS=" & Chr(34) & phoneNumBox.Text & Chr(34) & vbCrLf)
SerialPort.Write(message & Chr(26))
SentPicture.Visible = True
SentLabel.Visible = True
SentTimer.Start()
Else
MsgBox("Port not available")
End If
I Hope My Answer Was Useful To You.

Important Note
Port value change from time to another and from computer to another.
I will show you how to know port value of your device by pictures.
1:Enter to Device Manager from Control Panel.
2:Right click on the device, and choose Properties.
3:Choose Modem tap, and look for port name, and use it in your application.

Related

Telnet (winsock) connection in VBA - class not registered

I have GSM gateway that use telnet for sending/recivieng SMS. I'am making a small app in my ms-access for sending sms notifications for my clients. For that I need winsock connection from my client computer -> gsm gateway. It supposed to be easy :)
I can't establish an object. I'm receiving run-time error -2147221164(80040154) - Class not registered. Error is indicated in "Set winsock = ..." line. I have added reference MS Winsock Control 6.0 (SP6) - MSWINSCK.OCX. I have a feeling this is a problem with reference, but I don't have any idea how to correct it (code below is simplified) :( .
Option Explicit
Private WithEvents Winsock1 As Winsock
Sub Start_Telnet_Session()
Dim Data As String
Dim Winsock1
Set Winsock1 = New MSWinsockLib.Winsock
Winsock1.RemoteHost = "192.168.1.1"
Winsock1.RemotePort = "23"
Winsock1.connect
Do Until Winsock1.State = 7
DoEvents
If Winsock1.State = sckError Then
Exit Sub
End If
Loop
Winsock1.SendData "user" & vbCrLf
Winsock1.SendData "pass" & vbCrLf
Dim I As Integer
I = 5
While TelnetCommands <> ""
Winsock1.SendData "TelnetCommands" & vbCrLf
Winsock1.GetData Data
Data = VBA.Replace(Data, vbLf, "")
Data = VBA.Replace(Data, vbCr, vbNewLine)
MsgBox Data
I = I + 1
Wend
Winsock1.Close
End Sub

Radio.SetStateAsync(RadioState) Method doesn't work for MobileBroadband RadioKind (VB+Windows10)

I want to control RadioState of Wifi and Mobile(cellular) connection in Windows 10 x64 using custom application written in VB. It works for Wifi radio but doesn't for MobileBroadband.
Actually code does the same job as click on ActionCenter in Windows 10 and press Wifi or Cellular button.
Private Async Sub TurnMobileOnOff(arg As Integer)
Dim access = Await Windows.Devices.WiFi.WiFiAdapter.RequestAccessAsync
Dim radios = Await Windows.Devices.Radios.Radio.GetRadiosAsync
If access = Windows.Devices.WiFi.WiFiAccessStatus.Allowed Then
For Each radio In radios
If radio.Kind = Windows.Devices.Radios.RadioKind.MobileBroadband Then
If arg = 1 Then
Await radio.SetStateAsync(Windows.Devices.Radios.RadioState.On)
RichTextBox1.AppendText(vbCrLf & "Mobile connection is turninng on")
ElseIf arg = 0 Then
Await radio.SetStateAsync(Windows.Devices.Radios.RadioState.Off)
RichTextBox1.AppendText(vbCrLf & "Mobile connection is turninng off")
End If
End If
Next
End If
End Sub
There's no error message, just radiostate is unchanged. The same code works for WiFi as expected.
Source:https://learn.microsoft.com/en-us/uwp/api/windows.devices.radios.radiostate
Thank for any help.

Retrieving weights from scales to excel

I have connected a weighing scale to my PC via an RS-232 to USB converter cable. My goal was to create a command button in excel 2007 that would place the weight from the scale into the selected cell. I got it to work using the following code in a userform.
Private Sub XMCommCRC1_OnComm()
Static sInput As String
Dim sTerminator As String
Dim Buffer As Variant
' Branch according to the CommEvent property
Select Case XMCommCRC1.CommEvent
Case XMCOMM_EV_RECEIVE
Buffer = XMCommCRC1.InputData ' Use Input property for MSComm
sInput = sInput & Buffer
If Worksheets("Settings").Range("Terminator") = "CR/LF" Then
sTerminator = vbCrLf
Else
sTerminator = vbCr
End If
If Right$(sInput, Len(sTerminator)) = sTerminator Then
XMCommCRC1.PortOpen = False
sInput = Left$(sInput, Len(sInput) - Len(sTerminator))
Select Case Left$(sInput, 2)
Case "ST", "S "
ActiveCell.Value = CDbl(Mid$(sInput, 7, 8))
ActiveCell.Activate
Case "US", "SD"
MsgBox "The balance is unstable."
Case "OL", "SI"
MsgBox "The balance is showing an eror value."
End Select
sInput = ""
End If
End Select
End Sub
Public Sub RequestBalanceData()
With Worksheets("Settings")
' Configure and open the COM port
If Not XMCommCRC1.PortOpen Then
XMCommCRC1.RThreshold = 1
XMCommCRC1.RTSEnable = True
XMCommCRC1.CommPort = .Range("COM_Port")
XMCommCRC1.Settings = .Range("Baud_Rate") & "," & _
.Range("Parity") & "," & _
.Range("Data_Bits") & "," & _
.Range("Stop_Bits")
XMCommCRC1.PortOpen = True
End If
' Send balance's "SI" (Send Immediate) command
' to request weighing data immediately
If .Range("Terminator") = "CR/LF" Then
XMCommCRC1.Output = "R" & vbCrLf
Else
XMCommCRC1.Output = "R" & vbCr
End If
End With
End Sub
I then created a command button with the following code.
Private Sub CommandButton1_Click()
UserForm1.RequestBalanceData
End Sub
When I click on the command button the weight is placed in the selected cell. However, this does not consistently happen. Sometimes when I click the button nothing will be placed in the cell, and I will have to click it multiple times until the weight is placed in the cell. I would like to fix this, but I'm not sure where to start. Is it a problem with the code itself, or is it more likely a problem with the converter or the scale itself?
Any help is appreciated.
Here is the scale: https://www.optimascale.com/product-page/op-915-bench-scale
Here is the converter cable: https://www.amazon.com/gp/product/B06XJZHCV8/ref=ox_sc_act_title_3?smid=A33N7O64F8FSDL&psc=1
Here is the tutorial I used for the code: http://www.msc-lims.com/lims/diybalance.html
Here is the ActiveX control from the tutorial that I used: http://www.hardandsoftware.net/xmcomm.htm
EDIT: I have done what Wedge has suggested and placed a Mgsbox sInput after my first End If. I have been getting inconsistent results. I am wondering if I need to change my scales sending format. The scale is currently set to sending format 4.
Here is the scale manual (sending formats are on page 21-23: https://docs.wixstatic.com/ugd/78eff6_e629ae5fe7004c7189060cca4bc7c3de.pdf
2ND EDIT:
I have connected my serial port to putty. My scale is in continuos sending mode. In putty the scale is consistently sending the following: ST,GS+ 0.00lb. However, when i try to enter the weight value in a cell, the message box sometimes displays that part of the data sent (ST,GS+ 0.00lb) has got cut off, or has been sent multiple times with one button press. Does anyone know how I would fix this?
3RD EDIT: It seems to me that the continuous sending mode (mode 4) my scale is set to is sending data too fast and is causing my code to mess up. I would like to try to make this work with the command request mode (mode 3), but I can't figure out how to properly parse the data string and place it into a cell. The sending format for command request mode is :
If anybody could help me figure out how to get this working I would greatly appreciate it.

Using a usb digital scale in vb.net

I am developing a FedEx shipping application and I am trying to get the scale to read either dynamically or when the user ships. I need help trying to connect and get data from a usb scale in vb.net. I know how to do it for a serialport but i have no idea for a usb. How would i go about this?
this is my serialport code that i tried getting the port name to read the usb, but it kept saying "port name does not contain COM/com in it".
Private Sub testScale()
Dim Data As String
SerialPort1.Close()
SerialPort1.PortName = "COM1"
SerialPort1.BaudRate = 9600
SerialPort1.Parity = IO.Ports.Parity.Odd
SerialPort1.DataBits = 7
SerialPort1.StopBits = IO.Ports.StopBits.Two
SerialPort1.Open()
SerialPort1.Write("W" & vbCr)
Data = SerialPort1.ReadExisting
txtOutput.Text = Data
SerialPort1.Close()
End Sub
I was able to achieve what i wanted using this site: http://www.bumderland.com/dev/USBHIDScale.html. Using the HidLibrary.dll and converting the C# code to vb.net.

Customer Display OR Pole Display

I do also want to know how can I Display Text on Pole Display.
I write the code with VB.net 2008.
Sample Code that I write is :
If SerialPort1.IsOpen = False Then SerialPort1.Open()
SerialPort1.Write("\r\n" & RichTextBox1.Text & vbCr, 0, RichTextBox1.TextLength)
System.Threading.Thread.Sleep(1000)
If SerialPort1.IsOpen = True Then SerialPort1.Close()
I got no errors but can't display on Pole Display.
Please help me.
Sorry,
Forgot to Say. I do setup the Serial port Like This:
SerialPort1.BaudRate = 1200
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = 1
SerialPort1.DataBits = 7
But It doesn't work. :(
sp = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
sp.Open();
// to clear the display
sp.Write(Convert.ToString((char)12));
// first line goes here
sp.WriteLine("Total : " + textBox1.Text + " RM" );
// 2nd line goes here
sp.WriteLine((char)13 + "Tendered:" + textBox2.Text + " RM");
sp.Close();
sp.Dispose();
sp = null;
Dim sp As SerialPort = New SerialPort("COM15", 9600, Parity.None, 8, StopBits.One)
sp.Open()
sp.Write(Convert.ToString(ChrW(12)))
sp.WriteLine("WELCOME HERE")
sp.WriteLine(ChrW(13) & "Total Amount:1200")
sp.Close()
sp.Dispose()
sp = Nothing
You need to setup the serial port - i.e. the baud rate, number of bits and number of stop bits. Read the display poles manual to get these settings.
edit
Before you write any code use a terminal program like windows hyper-terminal to confirm:
That your hardware is working.
if you are using the correct com port
if you are using the correct baud rate
If you need flow control (XON/XOF) or is it via hardware (RTS/CTS)
What commands you can send to the display- i.e. to clear the display & to move the top line
if the display pole dip switches are set-up correctly