You are on page 1of 11

NEA – Development Sample

Section 1 – Logging in
01/07/18

To begin, I created the interface for the logging in screen. I used labels to annotate the interface to
make it clear what the text boxes would represent and text boxes would allow the users to enter the
variables into the system. The button would act as the trigger to store the variables into the computer’s
memory and check for any validation.

Dim username As String


Dim password As String
Dim List_password As New List(Of String)
Dim score As Integer = 0

I then created the variables required for this section. I stored the username and passwords as a
string to start because the likelihood would be the user enters 0+ characters into the system
which would be best suited as a string. I then created a string array which the password
would be appended to, so each character was stored within its own index ready to be
validated later. Finally, I created a scoring system which would monitor whether the
password contained the required fields to pass the validation checks I had in place.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


'Stores the user name and passsword variables based on the values in the text
boxes
username = txt_username.Text
password = txt_pword.Text

'Appends string value password into an array using a for loop


For Each value In password
List_password.Add(value) ' adds each value from the string into the list
Next

Once the button is pressed, it executes the rest of the code for this section. To begin, the values stored
in the textboxes are transferred to the appropriate variables. The program then uses a for loop to
append each character within my password variable into the array.
MessageBox.Show("The password does not meet the requirements: Uppercase,
Lowercase, Numbers. Re enter")

'Identifies the length of the password and alters accordingly


If Len(password) < 8 Then
score = 0
MessageBox.Show("Too short please re enter")
If Len(password) > 24 Then
score = 0
MessageBox.Show("Too long, please re enter")
End If

Options.Show() 'if password meets conditions, move onto next form


Me.Hide() 'Hide current form

I then began creating validation routines for the password. I started with the length of the password,
declaring that it needed to be between 8-24 characters in length. If the password was out of these
bounds, the program should display an error message and allow the user to re-enter the password.

This worked successfully – when a four length password was entered the program identified the
password was too short via a message box.

05/07/18
As I moved onto the next section of my program – the next window, I noticed that when testing my
program, if the password that was entered was too short, it still moved on to the next page in the form,
despite being validated.
'Identifies the length of the If score = 0 Then
password and alters accordingly MessageBox.Show("The password
If Len(password) < 8 Then does not meet the requirements:
score = 0 Uppercase, Lowercase, Numbers. Re enter")
MessageBox.Show("Too short please re
enter") 'Identifies the length of the
If Len(password) > 24 Then password and alters accordingly
score = 0 ElseIf Len(password) < 8 Then
MessageBox.Show("Too long, please re score = 0
enter") MessageBox.Show("Too short
End If please re enter")
If Len(password) > 24 Then
Options.Show() 'if password meets MessageBox.Show("Too
conditions, move onto next form long, please re enter")
Me.Hide() 'Hide current form End If

Else
Options.Show() 'if password
meets conditions, move onto next form
Me.Hide() 'Hide current form

End If

This was due to “Options.Show()” section of the code being found after the if the statement rather
than within it. This meant that regardless of the length of the password, the program would still show
the next form and hide the current (left). Therefore, I copied this function within the if statement,
which only executed the lines of code if the password was within the bounds of the validation.

08/07/18
'Loops through the array to identify any uppercase values.
' Where there are uppervase values a point is awarded
For uppercounter = 0 To Len(password) - 1 'uses counter to identify each
character in array.
If Char.IsUpper(List_password(uppercounter)) Then ' identifies if
character in array if uppercase
uppercasescore = uppercasescore + 1 ' adds one score
Else
uppercasescore = uppercasescore - 1
End If
uppercounter += 1 'must add one to the counter to loop through each
Next
'If there are any upper case values present, 1 is added to the overall score
If uppercasescore > 0 Then ' adds 1 to overall score
score = 1
MessageBox.Show("There are uppercase characters in the password")
ElseIf uppercasescore <= 0 Then 'if equal to or less than 0 , sets score to 0
score = 0
MessageBox.Show("There are no uppercase characters in the password")
End If

'Loops through the array to identify any lowercase values.


' Where there are lower case value a point is awarded
For lowercounter = 0 To Len(password) - 1
If Char.IsUpper(List_password(lowercounter)) Then
lowercasescore = lowercasescore + 1
ElseIf lowercasescore <= 0 Then
lowercasescore = lowercasescore - 1
End If
lowercounter += 1

Next
'If there are any lower case values present, 1 is added to the overall score
If lowercasescore > 0 Then
score = 1
MessageBox.Show("There are lowercase characters in the password")
ElseIf numberscore <= 0 Then
score = 0
MessageBox.Show("There are no lowercase characters in the password")

End If

'Loops through the array to identify any lowercase values.


' Where there are lower case value a point is awarded
For numbercounter = 0 To Len(password) - 1
If Char.IsNumber(List_password(numbercounter)) Then
numberscore = lowercasescore + 1
Else
numberscore = lowercasescore - 1
End If

numbercounter += 1
I began to extend the validation within the password system to review whether it contained uppercase,
lowercase and number characters as this is what is expected within a strong password. Using a for
loop, the length of the array and a counter, the program loops through as character within the array
and identifies if that character is upper, lower or numerical. Where it is, the overall score is set to 1 for
each value to identify there is at least one of each and vice versa. The scoring system was used so
where there weren’t certain types of characters, these would be outputted to the user to re enter.
When testing, originally this did not work i.e it did not identify / set the score correctly. This was as a
result of the counter not increasing by 1 every time, which meant the same value in the array
(index[0] – value 1) was being checked every time. Therefore. I had to go back and add one to each
counter within the for loop to ensure it checked every character in the array rather than just the first.
Testing
Test Test Data Expected Result Actual Result
No
1 “Turton1234” User should be able to enter values in
“turton” the textbox.

Values can be entered into both text boxes.


2 “Turton1234” The button is clickable and executes
“turton” lines of code within that subroutine

A message box appears, suggesting the lines of code within the subroutine are being executed.
3 “Turton1234” By adding a line of code:
“turton” For Each value In password

List_password.Add(value) ' adds


each value from the string into
the list

MessageBox.Show(List_password(0)
)
Next

The program should be able to output


“t” is the first value within the array – identified as index[0] therefore the variable has been
the first character within the array –
correctly appended.
“t” – which confirms the values in the
password string have been correctly
appended.
4 “Turton1234” Testing the 3rd value in the array, using
“turton” the following line of code:
MessageBox.Show(List_password(2)
)
This should output character “r”

The following error occurred. This was because of the positioning of the message box in the
program:

For Each value In password


List_password.Add(value) ' adds each value from the string into the
list
MessageBox.Show(List_password(2))
Next

The line of code should be outside the for loop and outputted after the loop has finished:
5 “Turton1234” The program should identify there are
“turton” no uppercase values in the password.
6 “Turton1234” The program should identify there are
“TURTON” uppercase letter values in the
password.

7 “Turton1234” The program should identify the


“Turton” password contains an uppercase value,
regardless of it being singular.

The program did not recognise the first character was uppercase. When revisiting the code, this
was due to my condition to which points where added to the score:

For uppercounter = 0 To Len(password) - 1 'uses counter to identify each


character in array.
If Char.IsUpper(List_password(uppercounter)) Then ' identifies if
character in array if uppercase
uppercasescore = uppercasescore + 1 ' adds one score
Else
uppercasescore = uppercasescore - 1
End If
uppercounter += 1 'must add one to the counter to loop through each
Next
If uppercasescore > 0 Then ' adds 1 to overall score
score = 1
MessageBox.Show("There are uppercase characters in the password")
ElseIf uppercasescore <= 0 Then 'if equal to or less than 0 , sets score
to 0
score = 0
MessageBox.Show("There are no uppercase characters in the password")
End If

Even though a point is clearly added to the score, due to there being several lowercase values
this sets the points below 0 (1 point for the first upper, then several points subtracted for the
remaining lowercase values). This means the overall score is set to a minus value, which
executes the message box “must add 1”.
By adding “exit for”, this breaks the loop as soon as an uppercase value is found.
8
9
10
11
12
13
14
15
16

You might also like