Here is my Tic Tac Toe game source code. I had a "Guess My Number" game but I lost the source code sorry. That would of told you how to setup a randomizer. But it sounds like your looking basic game code anyway. This is for Visual Basic so may need conversion from Vb to DB but should give you a good idea.
Public Class Form9
Dim Xturn As Boolean
Dim Oturn As Boolean
Dim turnno As Byte
Dim turn1 As Boolean
Dim turn2 As Boolean
Dim turn3 As Boolean
Dim turn4 As Boolean
Dim turn5 As Boolean
Dim turn6 As Boolean
Dim turn7 As Boolean
Dim turn8 As Boolean
Dim turn9 As Boolean
Dim o1o As Boolean
Dim o2o As Boolean
Dim o3o As Boolean
Dim o4o As Boolean
Dim o5o As Boolean
Dim o6o As Boolean
Dim o7o As Boolean
Dim o8o As Boolean
Dim o9o As Boolean
Dim x1x As Boolean
Dim x2x As Boolean
Dim x3x As Boolean
Dim x4x As Boolean
Dim x5x As Boolean
Dim x6x As Boolean
Dim x7x As Boolean
Dim x8x As Boolean
Dim x9x As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Xturn = True Then
x1.BringToFront()
x1x = True
End If
If Oturn = True Then
o1.BringToFront()
o1o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Xturn = True Then
x2.BringToFront()
x2x = True
End If
If Oturn = True Then
o2.BringToFront()
o2o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Xturn = True Then
x3.BringToFront()
x3x = True
End If
If Oturn = True Then
o3.BringToFront()
o3o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Xturn = True Then
x4.BringToFront()
x4x = True
End If
If Oturn = True Then
o4.BringToFront()
o4o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If Xturn = True Then
x5.BringToFront()
x5x = True
End If
If Oturn = True Then
o5.BringToFront()
o5o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If Xturn = True Then
x6.BringToFront()
x6x = True
End If
If Oturn = True Then
o6.BringToFront()
o6o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If Xturn = True Then
x7.BringToFront()
x7x = True
End If
If Oturn = True Then
o7.BringToFront()
o7o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If Xturn = True Then
x8.BringToFront()
x8x = True
End If
If Oturn = True Then
o8.BringToFront()
o8o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If Xturn = True Then
x9.BringToFront()
x9x = True
End If
If Oturn = True Then
o9.BringToFront()
o9o = True
End If
If turn9 = True Then
Goturn9()
End If
If turn8 = True Then
goturn8()
End If
If turn7 = True Then
goturn7()
End If
If turn6 = True Then
goturn6()
End If
If turn5 = True Then
goturn5()
End If
If turn4 = True Then
goturn4()
End If
If turn3 = True Then
goturn3()
End If
If turn2 = True Then
goturn2()
End If
If turn1 = True Then
goturn1()
End If
End Sub
Sub goturn1()
Xturn = False
Oturn = True
turn1 = False
turn2 = True
turnno = turnno + 1
End Sub
Sub goturn2()
Xturn = True
Oturn = False
turn2 = False
turn3 = True
turnno = turnno + 1
End Sub
Sub goturn3()
Xturn = False
Oturn = True
turn3 = False
turn4 = True
turnno = turnno + 1
End Sub
Sub goturn4()
Xturn = True
Oturn = False
turn4 = False
turn5 = True
turnno = turnno + 1
End Sub
Sub goturn5()
Xturn = False
Oturn = True
turn5 = False
turn6 = True
winthegame()
turnno = turnno + 1
End Sub
Sub goturn6()
Xturn = True
Oturn = False
turn6 = False
turn7 = True
winthegame()
turnno = turnno + 1
End Sub
Sub goturn7()
Xturn = False
Oturn = True
turn7 = False
turn8 = True
winthegame()
turnno = turnno + 1
End Sub
Sub goturn8()
Xturn = True
Oturn = False
turn8 = False
turn9 = True
winthegame()
turnno = turnno + 1
End Sub
Sub goturn9()
Xturn = False
Oturn = True
turn9 = False
winthegame()
turnno = turnno + 1
End Sub
Sub winthegame()
'X cond/*
'left to right/right to left
If x1x = True And x2x = True And x3x = True Then
MsgBox("X wins press play to play again")
End If
If x4x = True And x5x = True And x6x = True Then
MsgBox("X wins press play to play again")
End If
If x7x = True And x8x = True And x9x = True Then
MsgBox("X wins press play to play again")
End If
'up and down
If x1x = True And x4x = True And x7x = True Then
MsgBox("X wins press play to play again")
End If
If x2x = True And x5x = True And x8x = True Then
MsgBox("X wins press play to play again")
End If
If x3x = True And x6x = True And x9x = True Then
MsgBox("X wins press play to play again")
End If
'diagnal
If x1x = True And x5x = True And x9x = True Then
MsgBox("X wins press play to play again")
End If
If x3x = True And x5x = True And x7x = True Then
MsgBox("X wins press play to play again")
End If
'End X cond/*
'Begin O Cond
'left to right/right to left
If o1o = True And o2o = True And o3o = True Then
MsgBox("O wins press play to play again")
End If
If o4o = True And o5o = True And o6o = True Then
MsgBox("O wins press play to play again")
End If
If o7o = True And o8o = True And o9o = True Then
MsgBox("O wins press play to play again")
End If
'up and down
If o1o = True And o4o = True And o7o = True Then
MsgBox("O wins press play to play again")
End If
If o2o = True And o5o = True And o8o = True Then
MsgBox("O wins press play to play again")
End If
If o3o = True And o6o = True And o9o = True Then
MsgBox("O wins press play to play again")
End If
'diagnal
If o1o = True And o5o = True And o9o = True Then
MsgBox("O wins press play to play again")
End If
If o3o = True And o5o = True And o7o = True Then
MsgBox("O wins press play to play again")
End If
'End O ond /*
If turnno = 9 Then
MsgBox("End of game please press play to begin a new game")
End If
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
turn1 = False
turn2 = False
turn3 = False
turn4 = False
turn5 = False
turn6 = False
turn7 = False
turn8 = False
turn9 = False
o1o = False
o2o = False
o3o = False
o4o = False
o5o = False
o6o = False
o7o = False
o8o = False
o9o = False
x1x = False
x2x = False
x3x = False
x4x = False
x5x = False
x6x = False
x7x = False
x8x = False
x9x = False
o1.SendToBack()
o2.SendToBack()
o3.SendToBack()
o4.SendToBack()
o5.SendToBack()
o6.SendToBack()
o7.SendToBack()
o8.SendToBack()
o9.SendToBack()
x1.SendToBack()
x2.SendToBack()
x3.SendToBack()
x4.SendToBack()
x5.SendToBack()
x6.SendToBack()
x7.SendToBack()
x8.SendToBack()
x9.SendToBack()
play()
End Sub
Sub play()
MsgBox("X Goes First")
Xturn = True
Oturn = False
turnno = 1
turn1 = True
End Sub
Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
Me.Close()
End Sub
End Class
Hopw this helps