I copied and paste the following codes in my Class Library file. i have bold the codes with problems.
Option Explicit On
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 Private WithEvents DBServer As Postgres " PROBLEM - type 'Postgres' is not defined "
Public Event Sending(ByVal Done As Boolean)
Public Event DataReceived(ByVal Message As String)
Public Sub New(ByRef COMMPORT As String)
SMSPort = New SerialPort
.PortName = COMMPORT
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With DBServer = New Postgres() " PROBLEM - type 'Postgres' is not defined "
ReadThread = New Thread(AddressOf ReadPort)
Public Function SendSMS(ByVal CellNumber As String, ByVal SMSMessage As String) As Boolean
Dim MyMessage As String = Nothing
'Check if Message Length <= 160
If SMSMessage.Length <= 160 Then
MyMessage = SMSMessage
MyMessage = Mid(SMSMessage, 1, 160)
'MsgBox("Sending " & MyMessage & " to " & CellNumber)
If IsOpen = True Then
SMSPort.WriteLine("AT+CMGS=" & CellNumber & vbCr)
_ContSMS = False
While _ContSMS = False
SMSPort.WriteLine(MyMessage & vbCrLf & Chr(26))
_Continue = False
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
While SMSPort.IsOpen = True
If (SMSPort.BytesToRead <> 0) And (SMSPort.IsOpen = True) Then
While SMSPort.BytesToRead <> 0
SMSPort.Read(RXBuffer, 0, SMSPort.ReadBufferSize) 'SMSPort.BytesToRead
SerialIn = SerialIn & System.Text.Encoding.ASCII.GetString(RXBuffer)
' Handle Internal Events
' For Received Characters
If SerialIn.Contains(">") = True Then
_ContSMS = True
If SerialIn.Contains("+CMGS:") = True Then
_Continue = True
_Wait = False
SerialIn = String.Empty
SerialIn = String.Empty
Public ReadOnly Property IsOpen() As Boolean
If SMSPort.IsOpen = True Then
IsOpen = True
IsOpen = False
Public Sub Open()
If IsOpen = False Then
Public Sub Close()
If IsOpen = True Then
Next, i have also copied the following codes below into my windows form. I'm not sure if i've pasted the codes in the write place but that is wat i have done.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SMSEngine = New SMSCOMMS("COM1")
SMSEngine.SendSMS("919888888888", "SMS Testing")
The problem i faced is that the SMSEngine was not declared. How do i solve this?
THANKS IN ADVANCE!!
If you took the time to try and understand the code instead of just Copy'N'Paste what you don't understand and expecting it to work, then you would realize that this code uses a Postgres database for something that probably has nothing to do with sending SMS messages. It looks like you can get rid of those two lines and not worry about them.
I have no idea hwere you placed any of this stuff in your app.
How do i define or declare the SMSEngine in the codes?
What SMS Engine? Your code snippet doesn't mention anything about an engine. Or are you saying that the code you posted IS the engine? If so, then your problems do not lie in knowing VB.NET, but the basic concepts of object oriented programming. These are design issues that I really can't walk you through in a forum post.
The same program is executing successfully in our production environment but not in one of the development environment. We came to know that the program referring to STDOLE.DLL which is not there on the development machine where the program fails. Even if we copy the same dll on that machine, it is not working. How can we install Primary Interop Assemblies seperately? we do not want to install Visual studio.net.
Please let me know what are all the dlls required to use GETOBJECT() method in VB.Net program?
Are you sure the ActiveX component is correctly registered? The error you get is not an error of the GetObject function but that your ActiveX component is not registered correctly.
Try to registed the component by executing 'regsvr32 x:\path\myactivex.dll'.
We do not have STDOLE.DLL on our machine. So it cannot be registered right? What is required to install on the machine to get this dll? once again reminding you we do not want to install Visual studio.Net.
I would like to understand:
Does the program, written on the machine which VS.net is installed on, run succesfully?
If yes, you have to create a new setup project including all the required files (also STDOLE.dll) and then run it in the relevant computer.
Do I understood correctly what you need?
I want to write a programme. It's mantality is as same as Autoit. I have a windows form and when ı clicked to Button, ı want to send 1 or 2 or Ctrl+Alt+F2. My friend is playing a game and said me: can you do this? I said yes. Soooo... I use Sendkeys.send() as below:
First, controlling another application using SendKeys is about the poorst method you can use. SendKeys send keystrokes to whichever window with the focus, without caring about which window has the focus! You could be sending keystroked to Notepad when you actually wanted Calculator. There is no way to guarantee that every keystroke you send is going to end up going to the correct window.
Next, why are you converting the Keys to Characters?? Just send the Keys valoue, not the converted Chr value.
I use it but it sent 1(but Text form of 1 - string)
I don't have the slightest clue what you're trying to say here. This doesn't make any sense at all.