Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- 'This is my array variable, it will allow me to store data'
- Dim i As Integer
- 'This is my second array variable, it does exactly the same job'
- Dim j As Integer
- 'These are my other variables I will assign a value or scentence to'
- Dim Name As String
- Dim Postcode As String
- Dim NumberArray(7) As Integer
- Dim check_digit As Integer
- Dim total As Integer
- Dim cardnumber As Integer
- Dim expiredate As Date
- Dim time As Date
- 'This code allows me to check the expirey date of the loyalty card'
- time = System.DateTime.Today
- expiredate = TextBox4.Text
- If expiredate < time Then
- MessageBox.Show("Your card is out of date")
- Stop
- End If
- 'This assigns the text in TextBox3 as the Name'
- Name = (TextBox3.Text)
- 'This assigns the text and numbers in TextBox2 as the Postcode'
- Postcode = (TextBox2.Text)
- 'This assigns the numbers in Textbox1 as the card number'
- cardnumber = (TextBox1.Text)
- For i = 0 To 7
- NumberArray(i) = TextBox1.Text.Substring(i, 1)
- Next
- 'This stores the 8th digit as check_digit'
- check_digit = NumberArray(7)
- 'This will reverse the remaining 7 digits'
- Array.Reverse(NumberArray)
- For j = 0 To 6
- NumberArray(j) = TextBox1.Text.Substring(j, 1)
- Next
- 'This multiplies the required numbers by 2'
- NumberArray(0) = NumberArray(0) * 2
- NumberArray(2) = NumberArray(2) * 2
- NumberArray(4) = NumberArray(4) * 2
- NumberArray(6) = NumberArray(6) * 2
- 'If the multiplication answer is greater than 9 this code then takes away 9 from the answer'
- If NumberArray(0) > 9 Then
- NumberArray(0) = NumberArray(0) - 9
- End If
- If NumberArray(2) > 9 Then
- NumberArray(2) = NumberArray(2) - 9
- End If
- If NumberArray(4) > 9 Then
- NumberArray(4) = NumberArray(4) - 9
- End If
- If NumberArray(6) > 9 Then
- NumberArray(6) = NumberArray(6) - 9
- End If
- 'This adds the altered numbers and the normal numbers together as well as the 8th digit(check_digit)'
- total = NumberArray(0) + NumberArray(1) + NumberArray(2) + NumberArray(3) + NumberArray(4) + NumberArray(5) + NumberArray(6) + check_digit
- 'This checks if the total is directly divisible by ten'
- If total Mod 10 = 0 Then
- 'This displays whetheror not the card is valid'
- MessageBox.Show("Name " & Name)
- MessageBox.Show("Postcode " & Postcode)
- MessageBox.Show("Your card Number " & cardnumber)
- MessageBox.Show(total)
- MessageBox.Show("Your loyalty card is valid ")
- ElseIf MessageBox.Show("Name " & Name) Then
- MessageBox.Show("Postcode " & Postcode)
- MessageBox.Show("Your card Number " & cardnumber)
- MessageBox.Show(total)
- MessageBox.Show("Your loyalty card is invalid ")
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement