I have a working excel vba program, which allows to invoice the services and to take the appointments of the customers. I would like that each time an invoice is issued, the customer receives a thank you message for the amount of the invoice by sms. Also when a client's appointment is recorded, he gets an acknowledgment of receipt.
A similar problem has already been dealt with here. However there are items below that I did not understand in this code.
My knowledge of vba is really basic. Can you help me please.
Below is the code, as well as the lines which I don't understand.
thank you in advance
THE CODE
Sub send_SMS(xyz As Integer)
Application.ScreenUpdating = False
' Declaring varibles for sending sms
Dim HttpReq As New WinHttpRequest
Dim response As String
Dim sURL As String
Dim smsto, smstext As String
' Declaring varibles for Application
Dim lastrow, lastrow1, lastrow2, x, pointe As Long
lastrow = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
lastrow1 = Sheets(2).Range("A" & Rows.Count).End(xlUp).Row
lastrow2 = Sheets(3).Range("A" & Rows.Count).End(xlUp).Row
' Caculation of red card points
If xyz = 1 Then
pointe = (frmmain.txtpointe.Value - frmmain.txtpointr.Value) + (frmmain.txtamount.Value 10 / 100)
smstext = "Dear Member, You have reedemed " & frmmain.txtpointr.Text & " red points and your balance is " & pointe & " points"
Else
pointe = frmmain.txtpointe.Value + (frmmain.txtamount.Value * 10 / 100)
If pointe >= 1000 Then
smstext = "Dear Member, You have reached " & pointe & " red points and you can reedem it your next visit"
Else
smstext = "Dear Member, Your bill amount is " & frmmain.txtinvoice.Text & " and your Red Point balance is " & pointe & " Points"
End If
End If
' Checking for valid mobile number
If Len(frmmain.lblmobile.Caption) < 10 Then
Call nomobile(pointe)
Else
smsto = CStr(frmmain.lblmobile.Caption)
' //another way to create the HttpReq
Set HttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
' // API for sending sms
sURL = "malert.in/api/api_http.php?username=username&password=password&senderid=REDHCP&to=" & smsto & "&text=" & smstext & "&route=Enterprise&type=text"
' Debug.Print sURL
On Error Resume Next
With HttpReq
.Open "GET", sURL, False
.send
End With
response = HttpReq.responseText
HttpReq.waitForResponse
' MsgBox Left(response, 2)
Debug.Print response
If Left(response, 2) = "OK" Then
Call nomobile(pointe)
Else
Call errorconnection(smstext, pointe)
End If
End If
sURL = "malert.in/api/api_http_balance.php?username=username&password=password&route=Enterprise"
' Debug.Print sURL
On Error Resume Next
With HttpReq
.Open "GET", sURL, False
.send
End With
response = HttpReq.responseText
HttpReq.waitForResponse
frmmain.lblstatus.Caption = response
Debug.Print response
Application.ScreenUpdating = True
End Sub
The lines i dont understand
(xyz As Integer)
Dim lastrow, lastrow1, lastrow2, x, pointe As Long
lastrow = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
lastrow1 = Sheets(2).Range("A" & Rows.Count).End(xlUp).Row
lastrow2 = Sheets(3).Range("A" & Rows.Count).End(xlUp).Row
frmmain.txtpointe.Value + (frmmain.txtamount.Value
Bookmarks