FraserCunningham
Badges: 0
Rep:
?
#1
Report Thread starter 5 years ago
#1
I've been tasked with creating a game for my advanced higher project using VB6. It's a pairs game themed with Adventure Time pics etc. However I've hit a wall, and I'm not exactly sure why, here is the code:

Dim Grid1Index As String
Dim Grid2Index As String
Dim ClickCount As Integer
Dim I As Integer
Dim J As Integer


Private Sub Form_Load()


Dim Counter As Integer
Dim LoopCounter As Integer
LoopCounter = 1


For Counter = 0 To 35
Grid(Counter).Picture = Default
Next Counter


Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Finn"

Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Jake"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Rainicorn"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Bannana"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Beemo"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Pb"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Lich"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Fp"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Marceline"




Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Cake"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Ice_King"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Peppermint_Butler"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "TreeTrunks"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "LSP"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Gunter"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Lemongrab"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Doggy"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Fiona"

'tttttttttttttttt

Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Finn"

Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Jake"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Rainicorn"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Bannana"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Beemo"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Pb"



Do
Call Random
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Lich"





















End Sub
Private Sub Random()
Randomize
I = CInt(Int((5 * Rnd()) + 0))
J = CInt(Int((5 * Rnd()) + 0))
End Sub




Private Sub Grid_Click(index As Integer)
Dim IndexString As String
IndexString = index
Dim Tempi As Integer
Dim Tempj As Integer
Dim TagIndex As String


Dim RecordIndex1 As String
Dim RecordIndex2 As String
Dim Recordi1 As Integer
Dim Recordj1 As Integer
Dim Recordi2 As Integer
Dim Recordj2 As Integer


TagIndex = Grid(index).Tag
Tempi = Val(Mid(TagIndex, 1, 1))
Tempj = Val(Mid(TagIndex, 2, 1))


ClickCount = ClickCount + 1


If ClickCount = 1 Then
If GridArray(Tempi, Tempj) = "Finn" Then
Grid(index).Picture = Finn
Click1.Picture = Finn
ElseIf GridArray(Tempi, Tempj) = "Jake" Then
Grid(index).Picture = Jake
Click1.Picture = Jake
ElseIf GridArray(Tempi, Tempj) = "Rainicorn" Then
Grid(index).Picture = Rainicorn
Click1.Picture = Rainicorn
ElseIf GridArray(Tempi, Tempj) = "Beemo" Then
Grid(index).Picture = Beemo
Click1.Picture = Beemo
ElseIf GridArray(Tempi, Tempj) = "Pb" Then
Grid(index).Picture = Pb
Click1.Picture = Pb
ElseIf GridArray(Tempi, Tempj) = "Bannana" Then
Grid(index).Picture = Bannana
Click1.Picture = Bannana
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click1.Picture = Fiona
End If
Grid1Index = index
Recordi1 = Val(Mid(RecordIndex1, 1, 1))
Recordj1 = Val(Mid(RecordIndex1, 2, 1))
ElseIf ClickCount = 2 Then
If GridArray(Tempi, Tempj) = "Finn" Then
Grid(index).Picture = Finn
Click2.Picture = Finn
ElseIf GridArray(Tempi, Tempj) = "Jake" Then
Grid(index).Picture = Jake
Click2.Picture = Jake
ElseIf GridArray(Tempi, Tempj) = "Rainicorn" Then
Grid(index).Picture = Rainicorn
Click2.Picture = Rainicorn
ElseIf GridArray(Tempi, Tempj) = "Beemo" Then
Grid(index).Picture = Beemo
Click2.Picture = Beemo
ElseIf GridArray(Tempi, Tempj) = "Pb" Then
Grid(index).Picture = Pb
Click2.Picture = Pb
ElseIf GridArray(Tempi, Tempj) = "Bannana" Then
Grid(index).Picture = Bannana
Click2.Picture = Bannana
ElseIf GridArray(Tempi, Tempj) = "Fiona" Then
Grid(index).Picture = Fiona
Click2.Picture = Fiona
End If
Grid2Index = index
Recordi2 = Val(Mid(RecordIndex2, 1, 1))
Recordj2 = Val(Mid(RecordIndex2, 2, 1))
If Click2 <> Click2 Then
Grid(Grid1Index).Picture = Default
Grid(Grid2Index).Picture = Default
ClickCount = 0
Else
GridArray(Recordi1, Recordj1) = "Solved!"
GridArray(Recordi2, Recordj2) = "Solved!"
ClickCount = 0
End If
End If


End Sub


I've highlighted the code where the problem lies. It seems if I add anything more to that, the program can't execute, and I have to use CTRL + PAUSE BREAK to end the program. Any help would be much appreciated.
0
reply
ManicPumpkin
Badges: 3
Rep:
?
#2
Report 5 years ago
#2
(Original post by FraserCunningham)
x
I also do AH Computing but my programming skills aren't the best! However I will have a go at fixing your problem.

Instead of writing 'Call Random', you could write 'Random I,J'. So your code will look like this:

Do
Random I,J
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Jake"

This will (hopefully) tell the program to call the Random function.

However if you do this you will need to amend your Random function to this:

Private Sub Random(I as integer, J as integer )
Randomize
I = CInt(Int((5 * Rnd()) + 0))
J = CInt(Int((5 * Rnd()) + 0))
End Sub

I have no idea if this will work but I would give it a go

Posted from TSR Mobile
0
reply
FraserCunningham
Badges: 0
Rep:
?
#3
Report Thread starter 5 years ago
#3
(Original post by ManicPumpkin)
I also do AH Computing but my programming skills aren't the best! However I will have a go at fixing your problem.

Instead of writing 'Call Random', you could write 'Random I,J'. So your code will look like this:

Do
Random I,J
Loop Until GridArray(I, J) = ""
GridArray(I, J) = "Jake"

This will (hopefully) tell the program to call the Random function.

However if you do this you will need to amend your Random function to this:

Private Sub Random(I as integer, J as integer )
Randomize
I = CInt(Int((5 * Rnd()) + 0))
J = CInt(Int((5 * Rnd()) + 0))
End Sub

I have no idea if this will work but I would give it a go


Posted from TSR Mobile
I actually had this same idea today, however the code still crashes for some reason. Thanks for trying anyway, my programming skills aren't particularly good either :P
0
reply
ManicPumpkin
Badges: 3
Rep:
?
#4
Report 5 years ago
#4
(Original post by FraserCunningham)
I actually had this same idea today, however the code still crashes for some reason. Thanks for trying anyway, my programming skills aren't particularly good either :P
What are computers like, eh?
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

University open days

  • University of Bristol
    Undergraduate Open Afternoon Undergraduate
    Wed, 23 Oct '19
  • University of Exeter
    Undergraduate Open Day - Penryn Campus Undergraduate
    Wed, 23 Oct '19
  • University of Nottingham
    Mini Open Day Undergraduate
    Wed, 23 Oct '19

Have you made up your mind on your five uni choices?

Yes I know where I'm applying (154)
59.46%
No I haven't decided yet (60)
23.17%
Yes but I might change my mind (45)
17.37%

Watched Threads

View All