A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/Programming

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Sub Main()

Dim Names(4) As String 
Dim Current As Integer 
Dim Max As Integer 
Dim Found As Boolean 
Dim PlayerName As String 
Names(1) = "Ben" 
Names(2) = "Thor" 
Names(3) = "Zoe" 
Names(4) = "Kate" 
Max = 4 
Current = 1 
Found = False 
Console.WriteLine("What player are you looking 

for?")

PlayerName = Console.ReadLine 
While Found = False And Current <= Max 
If Names(Current) = PlayerName Then 
Found = True 
Else 
Current = Current + 1 
End If 
End While 
If Found = True Then 
Console.WriteLine("Yes, they have a top score") 
Else 
Console.WriteLine("No, they do not have a top 

score")

End If 
Console.ReadLine() 

End Sub