Option Explicit
Private WithEvents mySMSConnection As EasySMSClient
Private Sub cmd_Login_Click()
Dim ok As Boolean
ok = mySMSConnection.Connect(txt_username.Text, txt_password.Text)
If ok Then
logData "Connected to ViaNett"
End If
End Sub
Private Sub Form_Load()
Set mySMSConnection = New EasySMSClient
End Sub
Private Sub lstLog_DblClick()
lstLog.Clear
End Sub
Private Sub msg_Change()
characters_left.Caption = 160 - Len(msg.Text)
End Sub
Private Sub mySMSConnection_Status(ByVal Number As Integer, ByVal Description As String)
logData "Status:" & Description
End Sub
Private Sub Send_Click()
If Not IsNumeric(Tel.Text) Then MsgBox "invalid telephone number"
If Len(msg.Text) = 0 Then MsgBox "invalid text message"
If IsNumeric(Tel.Text) And Len(msg.Text) > 0 Then
Dim mySMS As sendSMSType
mySMS.msgID = mySMSConnection.getNextMsgId
mySMS.Tel = Tel.Text
mySMS.msg = msg.Text
Dim ok As Boolean
ok = mySMSConnection.sendSMS(mySMS)
If ok Then
logData "Message " & mySMS.msgID & " sent successfully to ViaNett"
Else
logData "Message " & mySMS.msgID & " failed, when sending the message to ViaNett"
End If
End If
End Sub
Private Sub mySMSConnection_OnError(ByVal Number As Integer, ByVal Description As String)
logData "Error: Number=" & Number & " Description=" & Description
End Sub
Sub mySMSConnection_ReceiveMsg(ByRef mySMS As receiveSMSType)
logData "Message Received: Tlf=" & mySMS.Tel & " msg=" & mySMS.msg
End Sub
Public Sub logData(ByVal logText As String)
Me.lstLog.AddItem Now() & " " & logText, 0
Debug.Print logText
Open App.Path & "\SMSLogg.txt" For Append As #1
Write #1, Now() & " " & logText
Close #1
End Sub
Sub mySMSConnection_ReceiveDelivery(ByRef myDelivery As SMSDeliveryType)
If myDelivery.ok Then
logData "Delivery: Message with id=" & myDelivery.msgID & " was sent sucessfully. The statuscode was " & myDelivery.ErrorCode
Else
logData "Delivery: Message with id=" & myDelivery.msgID & " failed. The errorcode was " & myDelivery.ErrorCode
End If
End Sub