01-03-2009, 11:42 AM
Right, well you said VB6 games. You didn't say what genre of game so I thought I'd add the first EVER VB6 application I made.
This was back in the day where I thought VB6 could be used to bring down the Government.
This is a simple application that I was told had to involve: Public Declarations, Call Sub, Call Function, Randomize, If Statements and Select Case. It had to be in the form of a 'game' and had to keep record of player's score.
I can't really be bothered to upload the .EXE so I'll just paste the source code and a screenshot. Lol
If you really are sad and want to see it run then go ahead and make it yourself.
[spoiler]![[Image: calcgame.jpg]](http://img26.imageshack.us/img26/2967/calcgame.jpg)
[/spoiler]
It's simple, it's messy, it's a waste. Atleast I got an A for it.
This was back in the day where I thought VB6 could be used to bring down the Government.
This is a simple application that I was told had to involve: Public Declarations, Call Sub, Call Function, Randomize, If Statements and Select Case. It had to be in the form of a 'game' and had to keep record of player's score.
I can't really be bothered to upload the .EXE so I'll just paste the source code and a screenshot. Lol
If you really are sad and want to see it run then go ahead and make it yourself.
[spoiler]
![[Image: calcgame.jpg]](http://img26.imageshack.us/img26/2967/calcgame.jpg)
Code:
Option Explicit
Public ans As Integer
Public Points As Integer
Private Sub Question()
Dim a As Integer
Dim b As Integer
Dim sym As Integer
Dim symbol As String
Randomize
a = Int(Rnd * 9) + 1
Randomize
b = Int(Rnd * 9) + 1
Randomize
sym = Int(Rnd * 3) + 1
Select Case sym
Case 0
symbol = " + "
ans = a + b
Case 1
symbol = " - "
ans = a - b
Case 2
symbol = " / "
ans = a / b
Case 3
symbol = " x "
ans = a * b
End Select
lblQuestion.Caption = CStr(a) & symbol & CStr(b)
End Sub
Private Function Score(ByVal i As Integer)
If i = ans Then
Points = Points + 1
txtAnswer.Text = ""
MsgBox "Correct!", vbOKOnly, "Score"
txtAnswer.SetFocus
Else
txtAnswer.Text = ""
MsgBox "Wrong! Correct Answer = " & ans, vbExclamation, "Score"
Points = Points
txtAnswer.SetFocus
End If
If Points = 25 Then
Dim NewGame As Integer
NewGame = MsgBox("Congratulations! You won!", vbYesNo, "GAME OVER")
If NewGame = vbYes Then
Points = 0
txtAnswer.Text = ""
txtAnswer.SetFocus
ElseIf NewGame = vbNo Then
Unload Me
End If
Else
'Do nothing
End If
Call UpdateScore(Points)
End Function
Private Function UpdateScore(ByVal i As Integer)
lblScore.Caption = "Score: " & i
End Function
Private Sub cmdSend_Click()
Call Score(CInt(txtAnswer.Text))
Call Question
End Sub
Private Sub Form_Load()
Points = 0
Call Question
Call UpdateScore(Points)
End Sub
It's simple, it's messy, it's a waste. Atleast I got an A for it.
