Using Graphics: Making a Lander Game - Part 3
This function returns a string containing the table, with the three columns, position, score and name separated by tabs. There is an optional parameter, BiggestScore, that allows only part of the table to be printed. If this is not specified, then the whole table is printed:
Public Function MakeScores(Optional BiggestScore As Integer) _ As String Dim makescore As Integer If BiggestScore > numberplaces Or IsEmpty(BiggestScore) = _ True Or BiggestScore = 0 Then BiggestScore = numberplaces MakeScores = IIf(ScoreOrder = BiggerIsBetter, "Bigger", _ "Smaller") & " is better" & vbNewLine & "Position" & vbTab _ & "Score" & vbTab & "Name" & vbNewLine & String(60, "-") For makescore = 1 To BiggestScore MakeScores = MakeScores & vbNewLine & makescore & ")" & _ vbTab & Scores(makescore).intScore & vbTab & _ Scores(makescore).strName Next End Function
The code is a lot easier to read all on one line, so load up VB, and all will be revealed.
Well, this is the end of my development of the Lander game. As usual, you can check out the demo to accompany this article. I hope you have gained some knowledge about programming a simple game in VB, and will continue to add features to the program.
If you have any questions or comments, you can post them in the feedback system below, or in the Q and A forum.
Page 6 of 6