Está en la página 1de 4

Option Explicit

Private WithEvents obj_clscom

As clsCom

'
'

/////////////////////////////////////////////////////////////

'

// Autor:

'

//

'

// Web:

'

//

'

//

|-> Pueden Distribuir Este codigo siempre y cuando

//

'

// no se eliminen los creditos originales de este codigo

//

'

// No importando que sea modificado/editado o engrandecido //

'

// o achicado, si es en base a este codigo

'

/////////////////////////////////////////////////////////////

'

//

BlackZeroX ( Ortega Avila Miguel Angel )

//
//

http://InfrAngeluX.Sytes.Net/

//
//

//

http://infrangelux.sytes.net/Blog/index.php?option=com_content&view=article&id
=6:artwait&catid=2:catprocmanager&Itemid=8
'

/////////////////////////////////////////////////////////////

Private Declare Function WaitMessage Lib "user32" () As Long

Enum eTime
Horas = 3600

Minutos = 60
Segundos = 1
End Enum

Public Sub Wait(ByVal vToWait&, Optional ByVal ThisWait As eTime = Segundos,


Optional ByVal UseAllProc As Boolean = False)
Dim vDateE

As Date

vDateE = DateAdd("s", vToWait& * (ThisWait + 0), Time)


Do While vDateE > Time
Call WaitMessage
If Not UseAllProc Then DoEvents
Loop
End Sub
Private Sub Form_Load()
Set obj_clscom = New clsCom
With obj_clscom
.ComPort = 4
.ComSettings = "57600,N,8,1"

' 57600 bps, sin paridad, 8 bits de

data, 1 bit de stop


.TimerDelay = 1000
entro data
.TimerEnabled = True
If .InitCom Then
Call .WriteCom("AT" & vbCr)

' 1000ms = 1 Segundo para chequear si

' wait()
Call .WriteCom("AT+CMGF=1" & vbCr)
' wait()
Call .WriteCom("AT+CMGS=" & Chr(34) & "0445526651140" & Chr(34) &
vbCr) ' // Segun el protocolo lo que nos retorna es +CMGS: <Num.
Identificador>
' wait()
Call .WriteCom("Espero una jalada en mi cel, aun que ya no tengo
credito xP" & Chr(26))

' 26 = Ctrl+Z ( Segun el protocolo AT )

End If
End With
End Sub

Private Sub Form_Unload(Cancel As Integer)


Set obj_clscom = Nothing
End Sub

Private Sub obj_clscom_DataReceived(ByVal strData As String)


Debug.Print strData
If InStr(1, strData, "+CMGS:") > 0 Then
If InStr(1, strData, "OK") > 0 Then
Dim str_Ret()

As String

str_Ret() = Split(Replace(Replace(strData, vbCr, ""), "OK", ""), "


")
Call obj_clscom.WriteCom("AT+CMSS=" & Val(str_Ret(1)) & vbCr)

End If
End If
End Sub

También podría gustarte