Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

how to check if all requirements are ok before sending a sms

$
0
0
i have a form that i send with it sms and i use a listview
now ..
i messed up my code trying to figure out how to fill and to check all values before sending
e.x if the credit for the sms is enough
if a person is not chosen from a listview then you cannot send
if a number of the sender is missing.
and if after all the values are ok then after i send the msgbox i get Sent successfully
this is the code im using now
Code:

Private Sub BttnSend_Click()
        If Txt(5).text = "" Then
        MsgBox "the phone of the sender is missing", vbExclamation
        Txt(5).SetFocus
        Exit Sub
        End If
         
        If Txt(1).text = 0 Then
        MsgBox "you credit for the sms is 0", vbExclamation
        Txt(1).SetFocus
      Exit Sub
      End If
     
If Label1.Caption > Txt(1).text Then(label1.caption counts the numbers of the customers from the DB"Label1.Caption = LsVw.ListItems.Count")
        MsgBox "The balance of your credit does not allow sending to the number of  the selected customers ", vbExclamation
      Exit Sub
      End If
     
   
    Dim SendToAll As String
    For i = 1 To LsVw.ListItems.Count
        If LsVw.ListItems(i).Checked And Len(Trim$(LsVw.ListItems(i).SubItems(1))) <> 0 Then
            SendToAll = SendToAll & LsVw.ListItems(i).SubItems(1) & "; "
        End If
    Next

    If SendToAll = vbNullString Then
   
        MsgBox "Please select at least one customer from the list", vbExclamation
       
        Check1.Value = vbUnchecked
        LsVw.SetFocus
    Exit Sub
   
   
        ElseIf Label1.Caption > Txt(1).text Then
        MsgBox "The balance of your credit does not allow sending a number of selected customers", vbExclamation
      Exit Sub
     
       
    Else
        retval = sendsms(UserSmsUid, UserSmsUn, Txtmsg, SendToAll, Txt(5).text)
        'ShellExecute hWnd, "open", "mailto:" & SendToAll, vbNullString, vbNullString, SW_SHOW
    End If
     
    Check1.Value = 0
   
    CmbGreeting.ListIndex = -1
    LsVw.SetFocus
    With LsVw
    For i = 1 To .ListItems.Count
        .ListItems(i).Checked = False
        .ListItems(i).Selected = False
 
    Next
   
    End With
    Call LoadCust
    Txt(5).text = ""
    MsgBox "Sent successfully", vbInformation
 
End Sub

if any more info is needed i will add
regards salsa31

Viewing all articles
Browse latest Browse all 21238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>