VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "CommSMSLib Example2"
   ClientHeight    =   6216
   ClientLeft      =   48
   ClientTop       =   336
   ClientWidth     =   5760
   LinkTopic       =   "Form1"
   ScaleHeight     =   6216
   ScaleMode       =   0  '使用者自訂
   ScaleWidth      =   5660
   StartUpPosition =   2  '螢幕中央
   Begin VB.Frame Frame3 
      Caption         =   "Function and Result"
      Height          =   1692
      Left            =   120
      TabIndex        =   17
      Top             =   4400
      Width           =   5532
      Begin VB.Label Label14 
         BorderStyle     =   1  '單線固定
         Caption         =   "Label14"
         Height          =   288
         Left            =   840
         TabIndex        =   21
         Top             =   1275
         Width           =   4565
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "Function"
         Height          =   180
         Left            =   150
         TabIndex        =   20
         Top             =   325
         Width           =   600
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "Result"
         Height          =   180
         Left            =   330
         TabIndex        =   19
         Top             =   1329
         Width           =   420
      End
      Begin VB.Label Label3 
         BorderStyle     =   1  '單線固定
         Caption         =   "Label3"
         Height          =   852
         Left            =   840
         TabIndex        =   18
         Top             =   325
         Width           =   4565
      End
   End
   Begin VB.CommandButton Command5 
      Caption         =   "More ..."
      Height          =   372
      Left            =   120
      TabIndex        =   16
      Top             =   3900
      Width           =   1029
   End
   Begin VB.Frame Frame2 
      Caption         =   "Caller Initialize/Terminate"
      Height          =   1200
      Left            =   120
      TabIndex        =   6
      Top             =   130
      Width           =   5532
      Begin VB.TextBox Text2 
         Height          =   288
         Left            =   1224
         TabIndex        =   12
         Text            =   "Text2"
         Top             =   720
         Width           =   1788
      End
      Begin VB.TextBox Text1 
         Height          =   288
         Left            =   1224
         TabIndex        =   11
         Text            =   "Text1"
         Top             =   350
         Width           =   1308
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Terminate"
         Height          =   372
         Left            =   4320
         TabIndex        =   8
         Top             =   675
         Width           =   1092
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Initialize"
         Height          =   372
         Left            =   4320
         TabIndex        =   7
         Top             =   240
         Width           =   1092
      End
      Begin VB.Label Label7 
         Caption         =   "Ex. 9600,n,8,1"
         Height          =   180
         Left            =   3150
         TabIndex        =   14
         Top             =   774
         Width           =   1092
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "Ex. 1"
         Height          =   180
         Left            =   2640
         TabIndex        =   13
         Top             =   404
         Width           =   372
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "CommPort"
         Height          =   180
         Left            =   402
         TabIndex        =   10
         Top             =   404
         Width           =   744
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "CommSettings"
         Height          =   180
         Left            =   150
         TabIndex        =   9
         Top             =   774
         Width           =   996
      End
   End
   Begin VB.CommandButton Command4 
      Caption         =   "Exit"
      Height          =   372
      Left            =   4623
      TabIndex        =   5
      Top             =   3900
      Width           =   1029
   End
   Begin VB.Frame Frame1 
      Caption         =   "Send Message"
      Height          =   2425
      Left            =   120
      TabIndex        =   0
      Top             =   1400
      Width           =   5532
      Begin VB.CommandButton Command8 
         Caption         =   "Stop"
         Height          =   372
         Left            =   4375
         TabIndex        =   28
         Top             =   720
         Width           =   1029
      End
      Begin VB.TextBox Text6 
         Height          =   288
         Left            =   3224
         TabIndex        =   26
         Text            =   "10"
         Top             =   840
         Width           =   1100
      End
      Begin VB.TextBox Text5 
         Height          =   288
         Left            =   1224
         TabIndex        =   23
         Text            =   "Text3"
         Top             =   850
         Width           =   1100
      End
      Begin VB.CheckBox Check1 
         Caption         =   "Unicode"
         Height          =   252
         Left            =   1250
         TabIndex        =   22
         Top             =   2105
         Value           =   1  '核取
         Width           =   1092
      End
      Begin VB.CommandButton Command3 
         Caption         =   "Send SMS"
         Height          =   372
         Left            =   4375
         TabIndex        =   4
         Top             =   275
         Width           =   1029
      End
      Begin VB.TextBox Text4 
         Height          =   875
         Left            =   1224
         TabIndex        =   3
         Text            =   "Text4"
         Top             =   1200
         Width           =   3100
      End
      Begin VB.TextBox Text3 
         Height          =   288
         Left            =   1224
         TabIndex        =   2
         Text            =   "0952205980"
         Top             =   282
         Width           =   3100
      End
      Begin VB.Label Label12 
         AutoSize        =   -1  'True
         Caption         =   "Loop"
         Height          =   180
         Left            =   2800
         TabIndex        =   27
         Top             =   888
         Width           =   360
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Phone No"
         Height          =   180
         Left            =   474
         TabIndex        =   25
         Top             =   336
         Width           =   672
      End
      Begin VB.Label Label11 
         AutoSize        =   -1  'True
         Caption         =   "Times"
         Height          =   180
         Left            =   726
         TabIndex        =   24
         Top             =   900
         Width           =   420
      End
      Begin VB.Label Label8 
         Caption         =   "Ex. +886932123123"
         Height          =   180
         Left            =   1300
         TabIndex        =   15
         Top             =   625
         Width           =   2772
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "Short Message"
         Height          =   180
         Left            =   150
         TabIndex        =   1
         Top             =   1150
         Width           =   996
      End
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public nCount   As Long
Public IsStop   As Boolean

Private Sub Command1_Click()
    ' Caller Terminate
    
    myComm.Terminate
    
    Me.Label3 = "myComm.Terminate"
    Me.Label14.Caption = ""
    
End Sub

Private Sub Command2_Click()

    ' Caller Initialize
    Dim String1 As Integer
    Dim String2 As String
    Dim Result As Boolean
    
    Dim String3 As String
    
    String1 = Val(Me.Text1.Text)
    String2 = Me.Text2.Text

    Result = myComm.Initialize(String1, String2)
    String3 = "myComm.Initialize(" & String1 & "," & Chr(34) & String2 & Chr(34) & ")"
    Me.Label3.Caption = String3
    Me.Label14.Caption = Result
    
    If Result Then
        MsgBox "Initialize OK!"
    Else
        MsgBox "Initialize Fail!"
    End If
    
End Sub

Private Sub Command3_Click()

    ' Send Short Message
    Dim String1 As String
    Dim String2 As String
    Dim Result As Boolean
    
    Dim String3 As String
    Dim IsUnicode As Boolean

    
    Dim StringIsUnicode As Boolean
    
    Dim myTimes As Long
    Dim i       As Long
    Dim nSuccess As Long
    Dim myLoop  As Long
    
    Dim myCount As Long
    
    String1 = Me.Text3.Text
    String2 = Me.Text4.Text
    
    If Me.Check1.Value = 1 Then
        IsUnicode = True
    Else
        IsUnicode = False
    End If
    
    nSuccess = 0
    myCount = 0
    
    StringIsUnicode = IsUnicodeSMS(String2)
    myTimes = Val(Me.Text5.Text)
    myLoop = Val(Me.Text6.Text)
    nCount = myTimes * myLoop
    
    If StringIsUnicode And Not IsUnicode Then
        MsgBox "The short message includes the Unicode!" & vbCrLf & _
               "Please send SMS by Unicode mode."
        Exit Sub
    End If
    
    IsStop = False
    Me.Command3.Enabled = False
    Me.Command8.Enabled = True
    For i = 1 To nCount
        DoEvents
        If IsStop Then
            Exit For
        End If
        Result = myComm.SendSMS(String1, i & " " & String2, IsUnicode)
        myCount = myCount + 1
        If Result Then
            nSuccess = nSuccess + 1
        End If
        String3 = "myComm.SendSMS(" & String1 & "," & Chr(34) & String2 & Chr(34) & "," & IsUnicode & ")"
        Me.Label3.Caption = String3
        Me.Label14.Caption = Result & "(" & nSuccess & "/" & nCount & ")"
    Next i
    
    MsgBox "SMS簡訊發送測試完畢！" & vbCrLf & _
           "測試總次數：" & myCount & "次" & vbCrLf & _
           "成功次數：" & nSuccess & "次", vbOKOnly, "SMS簡訊發送測試"
           
    Me.Command3.Enabled = True
    Me.Command8.Enabled = False
    
End Sub

Private Sub Command4_Click()

    Unload Me
    End
    
End Sub

Private Sub Command5_Click()

    Me.Height = 6475
    
End Sub

Private Sub Command8_Click()

    IsStop = True

End Sub

Private Sub Form_Load()

    Me.Text1.Text = 1
    Me.Text2.Text = "9600,n,8,1"
    Me.Text3.Text = "0952205980"
    Me.Text4.Text = ""
    Me.Text5.Text = 1
    Me.Height = 4750
    Me.Label3.Caption = ""
    Me.Label14.Caption = ""
    Me.Command8.Enabled = False
End Sub
