Advertisement
King_96

Laury solution

Jan 16th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.65 KB | None | 0 0
  1. ' Name:         Laury Project
  2. ' Purpose:      Displays a shipping charge based on the number of items ordered
  3. ' Programmer:   <Will H> on <01/15.15>
  4.  
  5. Option Explicit On
  6. Option Strict On
  7. Option Infer Off
  8.  
  9. Public Class frmMain
  10.  
  11.     Private strItems(,) As String = {{"1", "15"},
  12.                                      {"11", "10"},
  13.                                      {"51", "5"},
  14.                                      {"101", "FREE"}}
  15.  
  16.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  17.         Me.Close()
  18.     End Sub
  19.  
  20.     Private Sub txtordered_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtOrdered.KeyPress
  21.         ' allows the text box to accept numbers and the Backspace key
  22.  
  23.         If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
  24.             e.Handled = True
  25.         End If
  26.     End Sub
  27.  
  28.     Private Sub txtordered_TextChanged(sender As Object, e As EventArgs) Handles txtOrdered.TextChanged
  29.         lblShipping.Text = String.Empty
  30.     End Sub
  31.  
  32.     Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
  33.        
  34.         Dim strSearchForId As String
  35.         Dim intRow As Integer
  36.  
  37.         strSearchForId = txtOrdered.Text
  38.  
  39.         Do Until intRow > strItems.GetUpperBound(0) OrElse
  40.             strSearchForId = strItems(intRow, 0)
  41.             intRow += 1
  42.         Loop
  43.         If intRow <= strItems.GetUpperBound(0) Then
  44.             Dim intPrice As Integer
  45.             Integer.TryParse(strItems(intRow, 1), intPrice)
  46.             lblShipping.Text = intPrice.ToString("C0")
  47.  
  48.         End If
  49.  
  50.     End Sub
  51.  
  52. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement