Jump to content
xisto Community
William Wood

Visual Basic Projects: Scoreboard Making a scoreboard with Visual Basic 6

Recommended Posts

Hi again,

I've done another visual basic tutorial in this forum on how to make a simple, customized web browser. Now I am going to say how to make a scoreboard.

To do so, open a Standard EXE project in Visual Basic 6.0 and insert 6 labels and 2 command buttons. Change the captions on these to:

 

Label1: SCOREBOARD

Label2: LIONS

Label3: SWANS

Label4: 0

Label5: 0

Label6: Waiting for update...

 

Command1: TOUCHDOWN

Command2: TOUCHDOWN

 

Once you are done, it shoud look like this.

Posted Image

 

Press F5 now to see it in action. It won't do anything, seeing as how there is no path for it to follow. Now we ajust the coding part.

Double click anywhere on the project design. At the top, it should say 'Form1' or 'Command1' or 'Label1', etc. Change this to (General) and the one on the right to (Declarations).

 

Type this code where the cursor is blinking.

-----------------------------------

Option Explicit		  Dim TotalLions As Integer		  Dim TotalSwans As Integer
-----------------------------------

Now, change the coding place to Form1 and Load. Insert this programming now.

-----------------------------------

Private Sub Form_Load()		  Label1.Caption = SCOREBOARD		  Label4.Caption = 0		  Label5.Caption = 0		  Label6.Caption = GAME IS TIEDEnd Sub
-----------------------------------

Now in the Command1 coding place, insert this code.

-----------------------------------

Private Sub Command1_Click()		   Label4.Caption = Label4.Caption + 6		   TotalLions = TotalLions + 6				If TotalLions > TotalSwans Then				Label6.Caption = "LIONS LEAD"		   ElseIf TotalSwans > TotalLions Then				Label6.Caption = "SWANS LEAD"		   Else				Label6.Caption - "GAME IS TIED"End Sub
-----------------------------------

And on Command2 button, insert this code.

-----------------------------------

Private Sub Command2_Click()		   Label5.Caption = Label5.Caption + 6		   TotalSwans = TotalSwans + 6				If TotalSwans > TotalLions Then				Label6.Caption = "SWANS LEAD"		   ElseIf TotalLions > TotalSwans Then				Label6.Caption = "LIONS LEAD"		   Else				Label6.Caption - "GAME IS TIED"End Sub
-----------------------------------

 

I hope this has been useful. If you experience errors, please contact me :blink:.

 

Notice from WeaponX:
Please use CODE tags whenever you post any kind of code.

Share this post


Link to post
Share on other sites
How do I make the program run?Visual Basic Projects: Scoreboard

The lesson was great. I painted the Interface just like yours and in addition coded the program and it did compile but it never Displayed any thing on lble five and 6 at mouse click What is the problem?

-reply by Giddy TBay

 

Share this post


Link to post
Share on other sites

Seems to be very visual-basic-oriented.So, in order to make it run, you must know the vb interface, and know how to run the project you are creating.Maybe the visual basic online help can tell you how to run the main project.

Share this post


Link to post
Share on other sites
can anyone help cant get football scoreboard to work VB2010Visual Basic Projects: Scoreboard

I am building for a football team can enter their points and it will display points and total points and a final Score.The message box opens and you enter the point and the point then suppose to go into the listbox. I can't to get the points to go in the list box and calculate the final score. This my code could anyone please helpMe.

Dim strTotalofallScores As StringDim DecTotalofallScores As Decimal = 0DDim strInputMessage As String = "Enter the Score #"Dim strInputHeading As String = "Points Scored"Dim strNormalMessage As String = "Enter the Score #"Dim strNonnumericMessage As String = "Error-Enter a number for the Point Scored #"Dim strNegativeError As String = "Error-Enter a positive number for Points Scored#"' Declare and initialize loop variablesDim intMaxNumberOfEntries As Integer = 10Dim intNumberOfEntries As Integer = 1' This loop allows the user to enter the point Scored of up to 10 Scores' the loop terminates when the user has entered 10 scores or the userStrScores = InputBox (strInputMessage & intNumberOfEntries, strInputHeading, "")Do Until intNumberOfEntries > intMaxNumberOfEntries = decTotalofallScore()If IsNumeric (decScores) ThenDecScores = Convert.ToDecimal (strScores)If decScores > 0 ThenLstScores.Items.Add (decScores)DecTotalofallScores += DecTotalofallScoresIntNumberOfEntries += 1StrInputMessage = strNormalMessageElseStrInputMessage = strNegativeErrorEnd IfElseStrInputMessage = strNonnumericMessageEnd IfIf intNumberOfEntries <= intMaxNumberOfEntries ThenStrScores = InputBox (StrInputBoxMessage() & intNumberOfEntries, StringTrimming, "")End IfLoop' Makes label visibleLblTotalofallScore.Visible = True' Calculate and display average speedIf intNumberOfEntries > 1 ThenDecScores = decTotalofallScore()/(intNumberOfEntries - 1)LblTotalofallScore.Text = "Final Score is " & _DecTotalofallScore.ToString ("F1") & ""ElseLblTotalofallScore.Text = "No Score entered"End If'Disaables the Enter Score buttonBtnEnterScore.Enabled = False-question by linda

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.