SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit On
  2. Option Strict On
  3. Option Infer Off
  4. Public Class frmMain
  5.     'declare array at class level ?
  6.     Dim inAvailableDvds As IO.StreamReader
  7.     Dim strDVDs As String
  8.     Dim dblPrices() As Double
  9.  
  10.     Public Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
  11.         'display availableDVDs.txt on load
  12.         'assign to array and display first column
  13.         'if file exists, open file
  14.         If IO.File.Exists("availableDVDs.txt") Then
  15.             inAvailableDvds = IO.File.OpenText("availableDVDs.txt")
  16.  
  17.             'add items to listbox from file
  18.             Do Until inAvailableDvds.Peek = -1
  19.                 'read file
  20.                 strDVDs = inAvailableDvds.ReadLine
  21.                 'display titles - find and stop at comma
  22.                 lstDvds.Items.Add(strDVDs.Substring(0, strDVDs.IndexOf(",")))
  23.                 'find comma, pull remaining string
  24.                 Dim strTemp As String = strDVDs.Substring(strDVDs.IndexOf(",") + 1)
  25.                 'convert string to double
  26.  
  27.                 'assign to array
  28.             Loop
  29.             'bring selected index to first option and close file
  30.             lstDvds.SelectedIndex = 0
  31.             inAvailableDvds.Close()
  32.         End If
  33.  
  34.     End Sub
  35.     Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
  36.         'if no selection made, prompt user to select an item and set index to 0
  37.         'else add item to cart and remove from dvd list
  38.         If lstDvds.SelectedIndex = -1 Then
  39.             MessageBox.Show("Please select an item to add.")
  40.             lstDvds.SelectedIndex = 0
  41.         Else
  42.             'add item to cart
  43.             lstCart.Items.Add(lstDvds.SelectedItem)
  44.             'remove from dvds
  45.             lstDvds.Items.Remove(lstDvds.SelectedItem)
  46.  
  47.             'insert calculation method below
  48.             'CalculateTotals()
  49.         End If
  50.  
  51.     End Sub
  52.  
  53.     Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click
  54.         'if no selection is made (or no items in cart) prompt user to select an item
  55.         'else remove item from the cart and add it back to the dvd list
  56.         If lstCart.Items.Count = 0 Then
  57.             MessageBox.Show("Your cart is currently empty. Please add an item.")
  58.         ElseIf lstCart.SelectedIndex = -1 Then
  59.             MessageBox.Show("Please select an item to remove.")
  60.             lstCart.SelectedIndex = 0
  61.         Else
  62.             'add item back to dvds
  63.             lstDvds.Items.Add(lstCart.SelectedItem)
  64.             'remove item from cart
  65.             lstCart.Items.Remove(lstCart.SelectedItem)
  66.  
  67.             'insert calculation method below
  68.         End If
  69.  
  70.     End Sub
  71.  
  72.     Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
  73.         Dim strCustNumber As String = txtCustNum.Text
  74.  
  75.         If strCustNumber Like "####" Then
  76.             'store customer number and write to file
  77.  
  78.  
  79.  
  80.  
  81.         ElseIf strCustNumber = String.Empty Then 'check if empty
  82.             MessageBox.Show("Please enter a customer number to save this order before creating a new order.")
  83.         ElseIf strCustNumber <> "####" Then 'check for length
  84.             MessageBox.Show("The customer number must contain 4 digits.")
  85.         End If
  86.  
  87.     End Sub
  88.     Private Sub CalculateTotals()
  89.         Const dblTaxRate As Double = 0.04
  90.         Const intShippingCharge As Integer = 1
  91.         Dim dblSubtotal As Double
  92.  
  93.  
  94.         'temporary display placeholders
  95.  
  96.  
  97.         txtSubtotal.Text = dblSubtotal.ToString("C2")
  98.         'calculate tax amt * subtotal = tax
  99.         txtTax.Text = dblTaxRate.ToString("C2")
  100.         'calculate shipping - not > $5
  101.         txtShipping.Text = intShippingCharge.ToString("C2")
  102.  
  103.     End Sub
  104.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  105.         'exits application
  106.         Me.Close()
  107.     End Sub
  108. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top