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.


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.
-----------------------------------
CODE
Option Explicit
          Dim TotalLions As Integer
          Dim TotalSwans As Integer

-----------------------------------
Now, change the coding place to Form1 and Load. Insert this programming now.
-----------------------------------
CODE
Private Sub Form_Load()
          Label1.Caption = SCOREBOARD
          Label4.Caption = 0
          Label5.Caption = 0
          Label6.Caption = GAME IS TIED
End Sub

-----------------------------------
Now in the Command1 coding place, insert this code.
-----------------------------------
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.
-----------------------------------
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 smile.gif.

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

 

 

 


Comment/Reply (w/o sign-up)