Friday, December 23, 2011

Boggle

This is a type of words puzzle game where players can form as many words as possible from the characters displayed on a nxn square. Words can be formed in many ways, from left to right, from right to left, top to bottom, bottom to top, diagonal, zigzag manner and etc. You can actually play boggle online.
n this programme, I have designed a 5x5 boggle. Each time a player press the shake button, a different set of characters will appear. In order to do this, I use the randomize concept. This programme generates an array of 26 characters and displays them on an array of 24 labels by using  a For...Next loop . The procedure may look simple but it need a lot of thinking before we come out with the idea.

The Code

Dim char(25) As String

Dim I As Integer
Dim J As Integer

Private Sub Command1_Click()
char(0) = "A"
char(1) = "B"
char(2) = "C"
char(3) = "D"
char(4) = "E"
char(5) = "E"
char(6) = "G"
char(7) = "H"
char(8) = "I"
char(9) = "J"
char(10) = "K"
char(11) = "L"
char(12) = "M"
char(13) = "N"
char(14) = "O"
char(15) = "P"
char(16) = "Q"
char(17) = "R"
char(18) = "S"
char(19) = "T"
char(20) = "U"
char(21) = "V"
char(22) = "W"
char(23) = "X"
char(24) = "Y"
char(25) = "Z"

Randomize Timer
For I = 0 To 24
J = Int((Rnd * 26))
Label1(I).Caption = char(J)
Next

End Sub

No comments: