home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Sms_Sender2097221132008.psc / SmsSender / frmSendSms.frm next >
Text File  |  2008-01-13  |  11KB  |  327 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  3. Begin VB.Form frmSendSms 
  4.    Caption         =   "Sms Sender"
  5.    ClientHeight    =   8235
  6.    ClientLeft      =   60
  7.    ClientTop       =   450
  8.    ClientWidth     =   7320
  9.    BeginProperty Font 
  10.       Name            =   "Arial"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    Icon            =   "frmSendSms.frx":0000
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   8235
  21.    ScaleWidth      =   7320
  22.    StartUpPosition =   1  'CenterOwner
  23.    Begin VB.CommandButton cmdHide 
  24.       Caption         =   "Hide"
  25.       Height          =   345
  26.       Left            =   3720
  27.       TabIndex        =   12
  28.       ToolTipText     =   "Hide modem properties"
  29.       Top             =   7800
  30.       Width           =   1095
  31.    End
  32.    Begin SmsSender.GSM GSM 
  33.       Left            =   120
  34.       Top             =   7800
  35.       _extentx        =   873
  36.       _extenty        =   450
  37.    End
  38.    Begin VB.CommandButton cmdCancel 
  39.       Caption         =   "Done"
  40.       Height          =   345
  41.       Left            =   6120
  42.       TabIndex        =   8
  43.       Top             =   7800
  44.       Width           =   1095
  45.    End
  46.    Begin VB.CommandButton cmdSend 
  47.       Caption         =   "Send"
  48.       Enabled         =   0   'False
  49.       Height          =   345
  50.       Left            =   4920
  51.       TabIndex        =   7
  52.       Top             =   7800
  53.       Width           =   1095
  54.    End
  55.    Begin VB.Frame Frame2 
  56.       Caption         =   "Message"
  57.       Height          =   2655
  58.       Left            =   120
  59.       TabIndex        =   2
  60.       Top             =   5040
  61.       Width           =   7095
  62.       Begin VB.TextBox txtMessage 
  63.          Height          =   1575
  64.          Left            =   1200
  65.          MaxLength       =   320
  66.          MultiLine       =   -1  'True
  67.          TabIndex        =   5
  68.          Top             =   840
  69.          Width           =   5775
  70.       End
  71.       Begin VB.TextBox txtRecipient 
  72.          Height          =   345
  73.          Left            =   1200
  74.          TabIndex        =   3
  75.          Top             =   360
  76.          Width           =   5775
  77.       End
  78.       Begin VB.Label Label2 
  79.          AutoSize        =   -1  'True
  80.          Caption         =   "Message"
  81.          Height          =   210
  82.          Left            =   120
  83.          TabIndex        =   6
  84.          Top             =   720
  85.          Width           =   660
  86.       End
  87.       Begin VB.Label Label1 
  88.          AutoSize        =   -1  'True
  89.          Caption         =   "Recipient"
  90.          Height          =   210
  91.          Left            =   120
  92.          TabIndex        =   4
  93.          Top             =   360
  94.          Width           =   660
  95.       End
  96.    End
  97.    Begin VB.Frame Frame1 
  98.       Caption         =   "GSM Modem / Phone"
  99.       Height          =   4935
  100.       Left            =   120
  101.       TabIndex        =   0
  102.       Top             =   120
  103.       Width           =   7095
  104.       Begin VB.OptionButton optVoice 
  105.          Caption         =   "Cell"
  106.          Height          =   210
  107.          Left            =   6240
  108.          TabIndex        =   14
  109.          ToolTipText     =   "The gadget is actually a cellular phone mostly used for voice."
  110.          Top             =   360
  111.          Width           =   735
  112.       End
  113.       Begin VB.OptionButton optData 
  114.          Caption         =   "Data"
  115.          Height          =   210
  116.          Left            =   5520
  117.          TabIndex        =   13
  118.          ToolTipText     =   "The gadget is a data card that is mainly used for data calls"
  119.          Top             =   360
  120.          Width           =   735
  121.       End
  122.       Begin MSComctlLib.ListView lstReport 
  123.          Height          =   4095
  124.          Left            =   120
  125.          TabIndex        =   10
  126.          Top             =   720
  127.          Width           =   6855
  128.          _ExtentX        =   12091
  129.          _ExtentY        =   7223
  130.          LabelWrap       =   -1  'True
  131.          HideSelection   =   -1  'True
  132.          _Version        =   393217
  133.          ForeColor       =   -2147483640
  134.          BackColor       =   -2147483643
  135.          BorderStyle     =   1
  136.          Appearance      =   1
  137.          NumItems        =   0
  138.       End
  139.       Begin VB.ComboBox cboDevices 
  140.          Height          =   330
  141.          Left            =   1920
  142.          TabIndex        =   1
  143.          Text            =   "Combo1"
  144.          Top             =   360
  145.          Width           =   3495
  146.       End
  147.       Begin VB.Label lbl 
  148.          AutoSize        =   -1  'True
  149.          BackStyle       =   0  'Transparent
  150.          Caption         =   "Default Device"
  151.          Height          =   210
  152.          Index           =   3
  153.          Left            =   120
  154.          TabIndex        =   9
  155.          Top             =   360
  156.          Width           =   1050
  157.       End
  158.    End
  159.    Begin VB.Label lblMessage 
  160.       AutoSize        =   -1  'True
  161.       Caption         =   "lblMessage"
  162.       Height          =   210
  163.       Left            =   120
  164.       TabIndex        =   11
  165.       Top             =   7800
  166.       Width           =   810
  167.    End
  168. End
  169. Attribute VB_Name = "frmSendSms"
  170. Attribute VB_GlobalNameSpace = False
  171. Attribute VB_Creatable = False
  172. Attribute VB_PredeclaredId = True
  173. Attribute VB_Exposed = False
  174. Option Explicit
  175. Private Sub cboDevices_Click()
  176.     On Error Resume Next
  177.     ' read the devices connected to the computer
  178.     lblMessage.Caption = "Reading device properties..."
  179.     GSM.DeviceProperties cboDevices.Text, lstReport
  180.     optData.Value = False
  181.     optVoice.Value = False
  182.     lblMessage.Caption = ""
  183.     Err.Clear
  184. End Sub
  185. Private Sub cmdCancel_Click()
  186.     On Error Resume Next
  187.     GSM.DisConnect
  188.     Unload Me
  189.     Err.Clear
  190. End Sub
  191.  
  192. Private Sub cmdHide_Click()
  193.     Select Case cmdHide.Caption
  194.     Case "Hide"
  195.         cmdHide.Caption = "Show"
  196.         Me.Height = 4800
  197.         Frame1.Height = 855
  198.         Frame2.Top = 1080
  199.         lstReport.Visible = False
  200.         cmdHide.Top = 3840
  201.         cmdSend.Top = 3840
  202.         cmdCancel.Top = 3840
  203.         lblMessage.Top = 3840
  204.     Case Else
  205.         Frame2.Top = 5040
  206.         Me.Height = 8745
  207.         Frame1.Height = 4935
  208.         cmdHide.Caption = "Hide"
  209.         cmdHide.Top = 7800
  210.         cmdSend.Top = 7800
  211.         cmdCancel.Top = 7800
  212.         lblMessage.Top = 7800
  213.         lstReport.Visible = True
  214.     End Select
  215. End Sub
  216.  
  217. Private Sub cmdSend_Click()
  218.     On Error Resume Next
  219.     'send the message to the selected recipients
  220.     Dim mResult As String
  221.     Dim mPort As String
  222.     Dim mSpeed As String
  223.     Dim lPos As Long
  224.     Dim mRow() As String
  225.     Dim msgResult As Long
  226.     Dim rsCnt As Long
  227.     Dim rsTot As Long
  228.     Dim spNumbers() As String
  229.     Dim sendResult As New Collection
  230.     txtRecipient.Text = Trim$(txtRecipient.Text)
  231.     txtMessage.Text = Trim$(txtMessage.Text)
  232.     If cboDevices.ListIndex = -1 Then
  233.         Call MsgBox("The gsm modem type has not been chosem, please select data or voice.", vbOKOnly + vbExclamation + vbApplicationModal, "Gsm Modem Type")
  234.         Err.Clear
  235.         Exit Sub
  236.     End If
  237.     If Len(txtRecipient.Text) = 0 Then
  238.         Call MsgBox("The recipient(s) cannot be blank." & vbCr & "Please enter the receipient(s) cellular phone number or email address!", vbOKOnly + vbExclamation + vbApplicationModal, "Recipient(s) Error")
  239.         Err.Clear
  240.         Exit Sub
  241.     End If
  242.     Screen.MousePointer = vbHourglass
  243.     lblMessage.Caption = "Reading port number..."
  244.     mPort = 0
  245.     mSpeed = 0
  246.     ' find the port that the modem is connected to
  247.     lPos = GSM.LstViewFindItem(lstReport, "AttachedTo")
  248.     If lPos > 0 Then
  249.         mRow = GSM.LstViewGetRow(lstReport, lPos)
  250.         mPort = GSM.ExtractNumbers(mRow(2))
  251.     End If
  252.     lblMessage.Caption = "Reading speed..."
  253.     ' find the maximum connection rate as set as settings
  254.     '"460800,n,8,1"
  255.     lPos = GSM.LstViewFindItem(lstReport, "maxbaudratetoserialport")
  256.     If lPos > 0 Then
  257.         mRow = GSM.LstViewGetRow(lstReport, lPos)
  258.         mSpeed = mRow(2)
  259.     End If
  260. TryConnection:
  261.     Screen.MousePointer = vbHourglass
  262.     lblMessage.Caption = "Connecting to the device..."
  263.     ' connect to the modem/phone
  264.     If GSM.Connected = True Then GoTo SendMessage
  265.     mResult = GSM.Connect(mPort, mSpeed)
  266.     If optData.Value = True Then
  267.         GSM.ModemType = DataCard
  268.     ElseIf optVoice.Value = True Then
  269.         GSM.ModemType = Cellphone
  270.     End If
  271.     Select Case mResult
  272.     Case "OK"
  273.         lblMessage.Caption = "Reading message format..."
  274.         ' change the message format to text if it is not
  275.         mResult = GSM.SMS_MessageFormat(ReadFormat)
  276.         If mResult = "PDU" Then
  277.             lblMessage.Caption = "Setting message format to text..."
  278.             GSM.SMS_MessageFormat TextFormat
  279.         End If
  280.     Case Else
  281.         Screen.MousePointer = vbDefault
  282.         msgResult = MsgBox("A connection to the device could not be established!", vbRetryCancel + vbExclamation + vbApplicationModal, "Connection Error")
  283.         If msgResult = vbCancel Then Exit Sub
  284.         GoTo TryConnection
  285.     End Select
  286. SendMessage:
  287.     txtRecipient.Text = Replace$(txtRecipient, ";", ",")
  288.     spNumbers = Split(txtRecipient.Text, ",")
  289.     rsTot = UBound(spNumbers)
  290.     For rsCnt = 0 To rsTot
  291.         lblMessage.Caption = "Sending message to " & spNumbers(rsCnt) & "..."
  292.         mResult = GSM.SMS_Send(spNumbers(rsCnt), txtMessage.Text)
  293.         Select Case mResult
  294.         Case "OK"
  295.             sendResult.Add "Message was sent successfully to " & spNumbers(rsCnt)
  296.         Case Else
  297.         End Select
  298.         DoEvents
  299.     Next
  300.     lblMessage.Caption = ""
  301.     Screen.MousePointer = vbDefault
  302.     Err.Clear
  303. End Sub
  304. Private Sub Form_Load()
  305.     On Error Resume Next
  306.     ' load devices connected to the computer to the combobox
  307.     lblMessage.Caption = ""
  308.     GSM.LoadDevices cboDevices
  309.     GSM.LogFile = App.Path & "\sms sender.log"
  310.     Err.Clear
  311. End Sub
  312.  
  313. Private Sub GSM_Response(ByVal Result As String)
  314.     'Debug.Print Result
  315. End Sub
  316.  
  317. Private Sub txtMessage_Change()
  318.     On Error Resume Next
  319.     ' display how many characters are left and enable suitable buttons
  320.     If Len(txtMessage.Text) = 0 Then
  321.         cmdSend.Enabled = False
  322.     Else
  323.         cmdSend.Enabled = True
  324.     End If
  325.     Err.Clear
  326. End Sub
  327.