VERSION 5.00
Begin VB.Form frmInvoice 
   BackColor       =   &H00808000&
   Caption         =   "Form1"
   ClientHeight    =   9150
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   9645
   LinkTopic       =   "Form1"
   ScaleHeight     =   9150
   ScaleWidth      =   9645
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdClear 
      Cancel          =   -1  'True
      Caption         =   "CLEAR"
      Height          =   495
      Left            =   7200
      TabIndex        =   9
      Top             =   6360
      Width           =   2055
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "EXIT"
      Default         =   -1  'True
      Height          =   495
      Left            =   7200
      TabIndex        =   10
      Top             =   7200
      Width           =   2055
   End
   Begin VB.CommandButton cmdCalc 
      Caption         =   "CALCULATE"
      Height          =   495
      Left            =   7200
      TabIndex        =   8
      Top             =   5640
      Width           =   2055
   End
   Begin VB.ListBox lstCity 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   540
      Left            =   5880
      TabIndex        =   1
      Top             =   1200
      Width           =   2535
   End
   Begin VB.TextBox txtName 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   960
      TabIndex        =   0
      Text            =   "Text3"
      Top             =   1200
      Width           =   3135
   End
   Begin VB.TextBox Text2 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   2
      Left            =   4920
      TabIndex        =   7
      Text            =   "Text2"
      Top             =   4440
      Width           =   1815
   End
   Begin VB.TextBox Text2 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   1
      Left            =   4920
      TabIndex        =   5
      Text            =   "Text2"
      Top             =   3480
      Width           =   1815
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   2
      Left            =   1560
      MultiLine       =   -1  'True
      TabIndex        =   6
      Text            =   "Invoice.frx":0000
      Top             =   4440
      Width           =   3135
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   1
      Left            =   1560
      MultiLine       =   -1  'True
      TabIndex        =   4
      Text            =   "Invoice.frx":0006
      Top             =   3480
      Width           =   3135
   End
   Begin VB.TextBox Text2 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   4920
      TabIndex        =   3
      Text            =   "Text2"
      Top             =   2520
      Width           =   1815
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   1560
      MultiLine       =   -1  'True
      TabIndex        =   2
      Text            =   "Invoice.frx":000C
      Top             =   2520
      Width           =   3135
   End
   Begin VB.Label lblCredit 
      Alignment       =   2  'Center
      BackColor       =   &H000000FF&
      Caption         =   "CREDIT"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   495
      Index           =   2
      Left            =   7200
      TabIndex        =   24
      Top             =   4440
      Width           =   1575
   End
   Begin VB.Label lblCredit 
      Alignment       =   2  'Center
      BackColor       =   &H000000FF&
      Caption         =   "CREDIT"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   495
      Index           =   1
      Left            =   7200
      TabIndex        =   23
      Top             =   3480
      Width           =   1575
   End
   Begin VB.Label lblCredit 
      Alignment       =   2  'Center
      BackColor       =   &H000000FF&
      Caption         =   "CREDIT"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   495
      Index           =   0
      Left            =   7200
      TabIndex        =   22
      Top             =   2520
      Width           =   1575
   End
   Begin VB.Label Label13 
      BackColor       =   &H00808000&
      Caption         =   "Price"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4920
      TabIndex        =   21
      Top             =   2280
      Width           =   1335
   End
   Begin VB.Label Label12 
      BackColor       =   &H00808000&
      Caption         =   "Items"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1560
      TabIndex        =   20
      Top             =   2280
      Width           =   1335
   End
   Begin VB.Label Label11 
      BackColor       =   &H00808000&
      Caption         =   "City"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5880
      TabIndex        =   19
      Top             =   960
      Width           =   1695
   End
   Begin VB.Label Label10 
      BackColor       =   &H00808000&
      Caption         =   "Customer"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   960
      TabIndex        =   18
      Top             =   960
      Width           =   1695
   End
   Begin VB.Label lblTotal 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00C0FFFF&
      Caption         =   "Label9"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4920
      TabIndex        =   17
      Top             =   7200
      Width           =   1815
   End
   Begin VB.Label Label8 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00808000&
      Caption         =   "Final Total "
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3000
      TabIndex        =   16
      Top             =   7200
      Width           =   1695
   End
   Begin VB.Label Label7 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00808000&
      Caption         =   "Tax"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3000
      TabIndex        =   15
      Top             =   6480
      Width           =   1695
   End
   Begin VB.Label Label5 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00808000&
      Caption         =   "Subtotal"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3000
      TabIndex        =   14
      Top             =   5640
      Width           =   1695
   End
   Begin VB.Label lblTax 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00C0FFFF&
      Caption         =   "Label4"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4920
      TabIndex        =   13
      Top             =   6480
      Width           =   1815
   End
   Begin VB.Label lblSubTot 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00C0FFFF&
      Caption         =   "Label2"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4920
      TabIndex        =   12
      Top             =   5640
      Width           =   1815
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00C0FFFF&
      Caption         =   "INVOICE"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   24
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   2760
      TabIndex        =   11
      Top             =   120
      Width           =   3255
   End
   Begin VB.Menu mnuEdit 
      Caption         =   "Edit"
      Begin VB.Menu EditCut 
         Caption         =   "Cut"
      End
      Begin VB.Menu EditDelete 
         Caption         =   "Delete"
      End
      Begin VB.Menu EditCopy 
         Caption         =   "Copy"
      End
      Begin VB.Menu EditPaste 
         Caption         =   "Paste"
      End
   End
End
Attribute VB_Name = "frmInvoice"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Declare all needed variables.
'Note that variables follow naming conventions:
'  prefix sng for Single, str for String, etc.

    Dim i As Integer     'a loop counter usually doesn't have a prefix
    Dim sngPrice(2) As Single
    Dim sngSubTot As Single
    Dim sngTax As Single
    Dim sngTotal As Single
    Dim strCity As String
 
 Private Sub Form_Load()
 'When form opens it will be centered on the screen
    Me.Width = 10000
    Me.Height = 10000
    Me.Left = (Screen.Width - Me.Width) / 2
    Me.Top = (Screen.Height - Me.Height) / 2
    
  'The list is created when the form opens.
    lstCity.AddItem "Capital City"
    lstCity.AddItem "Beautiful City"
    lstCity.AddItem "Remote City"
    lstCity.AddItem "Mountain City"
    lstCity.AddItem "River City"
    
    Clear
   
End Sub

Private Sub Clear()
    sngSubTot = 0
    sngTax = 0
    sngTotal = 0
    
    lstCity.ListIndex = -1   'This clears the selected item in the list
        
    lblSubTot.Caption = ""
    lblTax.Caption = ""
    lblTotal.Caption = ""
    
    txtName = ""
    
    'This clears the control array.
    For i = 0 To 2
        Text1(i).Text = ""
        Text2(i).Text = 0
        lblCredit(i).Visible = False
    Next
    
End Sub



Private Sub Text2_Validate(Index As Integer, Cancel As Boolean)
    'Checking for Numeric value will avoid a crash
    'if user inputs text into variable declared as Single.
    If IsNumeric(Text2(Index).Text) Then
        If Text2(Index).Text > 50 Then
            MsgBox ("Too big!")
            Cancel = True
        End If
    Else
        MsgBox ("Must be numeric!")
        Cancel = True
    End If
    
End Sub

Private Sub cmdCalc_Click()
    For i = 0 To 2
        If Text2(i).Text <> 0 And Text1(i).Text = "" Then
            MsgBox ("Enter description")
            Text1(i).SetFocus
        End If
    Next i
    
    For i = 0 To 2
        sngPrice(i) = CSng(Text2(i).Text)
        sngSubTot = sngSubTot + sngPrice(i)
    Next i
    
   
    strCity = lstCity.Text
    If strCity = "Capital City" Then
        sngTax = sngSubTot * 0.08
    Else
        sngTax = 0
    End If
    
    sngTotal = sngSubTot + sngTax
    
    lblSubTot.Caption = Format(sngSubTot, "currency")
    lblTax.Caption = Format(sngTax, "currency")
    lblTotal.Caption = Format(sngTotal, "currency")
   
End Sub

Private Sub cmdClear_Click()
    Clear
End Sub

Private Sub cmdExit_Click()
    'Always use Unload instead of End to stop program.
    Unload Me     'Me is the active form
End Sub

Private Sub Text2_GotFocus(Index As Integer)
    Hilite
End Sub

Private Sub Hilite()
    ActiveControl.SelStart = 0
    ActiveControl.SelLength = Len(ActiveControl.Text)
End Sub

Private Sub Text2_LostFocus(Index As Integer)
    If Text2(Index).Text < 0 Then
        lblCredit(Index).Visible = True
    End If
End Sub

Private Sub EditCut_Click()
    ' Clear the contents of the Clipboard.
    Clipboard.Clear
    ' Copy selected text to Clipboard.
    Clipboard.SetText Screen.ActiveControl.SelText
    ' Delete selected text.
    Screen.ActiveControl.SelText = ""
End Sub

Private Sub EditCopy_Click()
    ' Clear the contents of the Clipboard.
    Clipboard.Clear
    ' Copy selected text to Clipboard.
    Clipboard.SetText Screen.ActiveControl.SelText
End Sub

Private Sub EditPaste_Click()
    ' Place text from Clipboard into active control.
    Screen.ActiveControl.SelText = Clipboard.GetText()
End Sub

Private Sub EditDelete_Click()
    ' Delete selected text.
    Screen.ActiveControl.SelText = ""
End Sub

