Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         'This is my array variable, it will allow me to store data'
  5.        Dim i As Integer
  6.         'This is my second array variable, it does exactly the same job'
  7.        Dim j As Integer
  8.         'These are my other variables I will assign a value or scentence to'
  9.        Dim Name As String
  10.         Dim Postcode As String
  11.         Dim NumberArray(7) As Integer
  12.         Dim check_digit As Integer
  13.         Dim total As Integer
  14.         Dim cardnumber As Integer
  15.         Dim expiredate As Date
  16.         Dim time As Date
  17.         'This code allows me to check the expirey date of the loyalty card'
  18.        time = System.DateTime.Today
  19.         expiredate = TextBox4.Text
  20.         If expiredate < time Then
  21.             MessageBox.Show("Your card is out of date")
  22.             Stop
  23.         End If
  24.  
  25.         'This assigns the text in TextBox3 as the Name'
  26.        Name = (TextBox3.Text)
  27.         'This assigns the text and numbers in TextBox2 as the Postcode'
  28.        Postcode = (TextBox2.Text)
  29.         'This assigns the numbers in Textbox1 as the card number'
  30.        cardnumber = (TextBox1.Text)
  31.  
  32.         For i = 0 To 7
  33.             NumberArray(i) = TextBox1.Text.Substring(i, 1)
  34.         Next
  35.         'This stores the 8th digit as check_digit'
  36.        check_digit = NumberArray(7)
  37.         'This will reverse the remaining 7 digits'
  38.        Array.Reverse(NumberArray)
  39.  
  40.         For j = 0 To 6
  41.             NumberArray(j) = TextBox1.Text.Substring(j, 1)
  42.         Next
  43.         'This multiplies the required numbers by 2'
  44.        NumberArray(0) = NumberArray(0) * 2
  45.         NumberArray(2) = NumberArray(2) * 2
  46.         NumberArray(4) = NumberArray(4) * 2
  47.         NumberArray(6) = NumberArray(6) * 2
  48.         'If the multiplication answer is greater than 9 this code then takes away 9 from the answer'
  49.        If NumberArray(0) > 9 Then
  50.             NumberArray(0) = NumberArray(0) - 9
  51.         End If
  52.         If NumberArray(2) > 9 Then
  53.             NumberArray(2) = NumberArray(2) - 9
  54.         End If
  55.         If NumberArray(4) > 9 Then
  56.             NumberArray(4) = NumberArray(4) - 9
  57.         End If
  58.         If NumberArray(6) > 9 Then
  59.             NumberArray(6) = NumberArray(6) - 9
  60.         End If
  61.         'This adds the altered numbers and the normal numbers together as well as the 8th digit(check_digit)'
  62.        total = NumberArray(0) + NumberArray(1) + NumberArray(2) + NumberArray(3) + NumberArray(4) + NumberArray(5) + NumberArray(6) + check_digit
  63.         'This checks if the total is directly divisible by ten'
  64.        If total Mod 10 = 0 Then
  65.             'This displays whetheror not the card is valid'
  66.            MessageBox.Show("Name " & Name)
  67.             MessageBox.Show("Postcode " & Postcode)
  68.             MessageBox.Show("Your card Number " & cardnumber)
  69.             MessageBox.Show(total)
  70.             MessageBox.Show("Your loyalty card is valid ")
  71.  
  72.         ElseIf MessageBox.Show("Name " & Name) Then
  73.             MessageBox.Show("Postcode " & Postcode)
  74.             MessageBox.Show("Your card Number " & cardnumber)
  75.             MessageBox.Show(total)
  76.             MessageBox.Show("Your loyalty card is invalid ")
  77.  
  78.         End If
  79.  
  80.  
  81.  
  82.     End Sub
  83. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement