Click here to Skip to main content
15,885,868 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: how can i connect crystal report to sqlserver with vb.net code ? Pin
helelark1239-Jul-09 0:58
helelark1239-Jul-09 0:58 
AnswerRe: how can i connect crystal report to sqlserver with vb.net code ? Pin
Tom Deketelaere9-Jul-09 4:00
professionalTom Deketelaere9-Jul-09 4:00 
Questionvisual basic help Pin
Member 44064419-Jul-09 0:30
Member 44064419-Jul-09 0:30 
AnswerRe: visual basic help Pin
helelark1239-Jul-09 0:56
helelark1239-Jul-09 0:56 
AnswerRe: visual basic help Pin
Christian Graus9-Jul-09 2:18
protectorChristian Graus9-Jul-09 2:18 
GeneralRe: visual basic help Pin
Tom Deketelaere9-Jul-09 2:30
professionalTom Deketelaere9-Jul-09 2:30 
GeneralRe: visual basic help Pin
Christian Graus9-Jul-09 2:37
protectorChristian Graus9-Jul-09 2:37 
QuestionProblems regarding the code to send sms using .Net Pin
gjx_junxian19898-Jul-09 23:56
gjx_junxian19898-Jul-09 23:56 
I got the codes to send sms using VB and i came across these two sample codes.

Sending SMS using .NET[^]

http://www.daniweb.com/forums/post250164-19.html#[^]

I copied and paste the following codes in my Class Library file. i have bold the codes with problems.

Option Explicit On
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.IO.Ports



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
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
DBServer = New Postgres() " PROBLEM - type 'Postgres' is not defined "
ReadThread = New Thread(AddressOf ReadPort)
End Sub

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
Else
MyMessage = Mid(SMSMessage, 1, 160)
End If
'MsgBox("Sending " & MyMessage & " to " & CellNumber)
If IsOpen = True Then
SMSPort.WriteLine("AT+CMGS=" & CellNumber & vbCr)
_ContSMS = False
While _ContSMS = False
Application.DoEvents()
End While
SMSPort.WriteLine(MyMessage & vbCrLf & Chr(26))
_Continue = False
RaiseEvent Sending(False)
End If
End Function


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
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 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


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.Open()
SMSEngine.SendSMS("919888888888", "SMS Testing")
SMSEngine.Close()
End Sub

The problem i faced is that the SMSEngine was not declared. How do i solve this?
THANKS IN ADVANCE!!
AnswerRe: Problems regarding the code to send sms using .Net Pin
Dave Kreskowiak9-Jul-09 4:06
mveDave Kreskowiak9-Jul-09 4:06 
GeneralRe: Problems regarding the code to send sms using .Net Pin
gjx_junxian19899-Jul-09 4:27
gjx_junxian19899-Jul-09 4:27 
GeneralRe: Problems regarding the code to send sms using .Net Pin
Dave Kreskowiak9-Jul-09 7:36
mveDave Kreskowiak9-Jul-09 7:36 
QuestionDLLs required to use GetObject() method in VB.Net Pin
Raheem MA8-Jul-09 19:59
Raheem MA8-Jul-09 19:59 
AnswerRe: DLLs required to use GetObject() method in VB.Net Pin
tosch8-Jul-09 20:11
tosch8-Jul-09 20:11 
GeneralRe: DLLs required to use GetObject() method in VB.Net Pin
Raheem MA8-Jul-09 20:40
Raheem MA8-Jul-09 20:40 
GeneralRe: DLLs required to use GetObject() method in VB.Net Pin
helelark1238-Jul-09 20:42
helelark1238-Jul-09 20:42 
GeneralRe: DLLs required to use GetObject() method in VB.Net Pin
Raheem MA8-Jul-09 22:14
Raheem MA8-Jul-09 22:14 
GeneralRe: DLLs required to use GetObject() method in VB.Net Pin
helelark1238-Jul-09 22:24
helelark1238-Jul-09 22:24 
GeneralRe: DLLs required to use GetObject() method in VB.Net Pin
Raheem MA9-Jul-09 0:04
Raheem MA9-Jul-09 0:04 
GeneralRe: DLLs required to use GetObject() method in VB.Net Pin
helelark1239-Jul-09 0:17
helelark1239-Jul-09 0:17 
Questionpreprocessor macro for function name? Pin
T21028-Jul-09 14:39
T21028-Jul-09 14:39 
AnswerRe: preprocessor macro for function name? Pin
helelark1238-Jul-09 19:13
helelark1238-Jul-09 19:13 
GeneralRe: preprocessor macro for function name? Pin
T21028-Jul-09 19:41
T21028-Jul-09 19:41 
GeneralRe: preprocessor macro for function name? Pin
helelark1238-Jul-09 19:51
helelark1238-Jul-09 19:51 
QuestionVB or VBA and Microsoft Works Database Pin
Dalek Dave8-Jul-09 9:59
professionalDalek Dave8-Jul-09 9:59 
AnswerRe: VB or VBA and Microsoft Works Database Pin
Henry Minute8-Jul-09 10:37
Henry Minute8-Jul-09 10:37 

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.