# jogo de sorteio.

### Question

• ```Public Class Form1
Dim numeros(5) As Integer
Dim a, b, c, d, f, g, contador As Integer

Private Sub btnjogar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnjogar.Click
tmrSorteio.Enabled = True
If a = b Or b = c Or c = d Or f = g Or a = c Or a = d Or a = f Or a = g Or b = d Or b = f Or b = g Or c = f Or c - g Or d = g Or f = g Or c = f Then
tmrSorteio.Enabled = True

End If
btnjogar.Enabled = False

End Sub

Private Sub tmrSorteio_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSorteio.Tick
Randomize()
a = Int(70 * Rnd() + 1)
txt1.Text = (a)
b = Int(70 * Rnd() + 1)
txt2.Text = (b)
c = Int(70 * Rnd() + 1)
txt3.Text = (c)
d = Int(70 * Rnd() + 1)
txt4.Text = (d)
f = Int(70 * Rnd() + 1)
txt5.Text = (f)
g = Int(70 * Rnd() + 1)
txt6.Text = (g)

numeros(0) = a
numeros(1) = b
numeros(2) = c
numeros(3) = d
numeros(4) = f
numeros(5) = g

If contador = 10 Then
tmrSorteio.Enabled = False
For i As Integer = 0 To 5

Next

For i As Integer = 0 To 5
For Me.d = 0 To 5

If ListBox1.Items(i) = ListBox2.Items(d) Then

ListBox3.Items.Add("voce acertou com o " & ListBox2.Items(d))

End If

Next
Next

End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

End Sub

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click

btn1.Enabled = False

End Sub

Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click

btn2.Enabled = False

End Sub

Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click

btn3.Enabled = False

End Sub

Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click

btn4.Enabled = False

End Sub

Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click

btn5.Enabled = False

End Sub

Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click

btn6.Enabled = False

End Sub

Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
btn7.Enabled = False

End Sub

Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click

btn8.Enabled = False

End Sub

Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click

btn9.Enabled = False

End Sub

Private Sub btn10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn10.Click

btn10.Enabled = False

End Sub

Private Sub btn11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn11.Click

btn11.Enabled = False

End Sub

Private Sub btn12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn12.Click

btn12.Enabled = False

End Sub

Private Sub btn13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn13.Click

btn13.Enabled = False

End Sub

Private Sub btn14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn14.Click

btn14.Enabled = False

End Sub

Private Sub btn15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn15.Click

btn15.Enabled = False

End Sub

Private Sub btn16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn16.Click

btn16.Enabled = False

End Sub

Private Sub btn17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn17.Click

btn17.Enabled = False

End Sub

Private Sub btn18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn18.Click

btn18.Enabled = False

End Sub

Private Sub btn19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn19.Click

btn19.Enabled = False

End Sub

Private Sub btn20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn20.Click

btn20.Enabled = False

End Sub

Private Sub btn21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn21.Click

btn21.Enabled = False

End Sub

Private Sub btn22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn22.Click

btn22.Enabled = False

End Sub

Private Sub btn23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn23.Click

btn23.Enabled = False

End Sub

Private Sub btn24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn24.Click

btn24.Enabled = False

End Sub

Private Sub btn25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn25.Click

btn25.Enabled = False

End Sub

Private Sub btn26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn26.Click

btn26.Enabled = False

End Sub

Private Sub btn27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn27.Click

btn27.Enabled = False

End Sub

Private Sub btn28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn28.Click

btn28.Enabled = False

End Sub

Private Sub btn29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn29.Click

btn29.Enabled = False

End Sub

Private Sub btn30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn30.Click

btn30.Enabled = False

End Sub

Private Sub btn31_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn31.Click

btn31.Enabled = False

End Sub

Private Sub btn32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn32.Click

btn32.Enabled = False

End Sub

Private Sub btn33_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn33.Click

btn33.Enabled = False

End Sub

Private Sub btn34_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn34.Click

btn34.Enabled = False

End Sub

Private Sub btn35_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn35.Click

btn35.Enabled = False

End Sub

Private Sub btn36_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn36.Click

btn36.Enabled = False

End Sub

Private Sub btn37_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn37.Click

btn37.Enabled = False

End Sub

Private Sub btn38_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn38.Click

btn38.Enabled = False

End Sub

Private Sub btn39_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn39.Click

btn39.Enabled = False

End Sub

Private Sub btn40_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn40.Click

btn40.Enabled = False

End Sub

Private Sub btn41_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn41.Click

btn41.Enabled = False

End Sub

Private Sub btn42_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn42.Click

btn42.Enabled = False

End Sub

Private Sub btn43_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn43.Click

btn43.Enabled = False

End Sub

Private Sub btn44_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn44.Click

btn44.Enabled = False

End Sub

Private Sub btn45_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn45.Click

btn45.Enabled = False

End Sub

Private Sub btn46_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn46.Click

btn46.Enabled = False

End Sub

Private Sub btn47_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn47.Click

btn47.Enabled = False

End Sub

Private Sub btn48_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn48.Click

btn48.Enabled = False

End Sub

Private Sub btn49_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn49.Click

btn49.Enabled = False

End Sub

Private Sub btn50_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn50.Click

btn50.Enabled = False

End Sub

Private Sub btn51_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn51.Click

btn51.Enabled = False

End Sub

Private Sub btn52_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn52.Click

btn52.Enabled = False

End Sub

Private Sub btn53_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn53.Click

btn53.Enabled = False

End Sub

Private Sub btn54_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn54.Click

btn54.Enabled = False

End Sub

Private Sub btn55_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn55.Click

btn55.Enabled = False

End Sub

Private Sub btn56_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn56.Click

btn56.Enabled = False

End Sub

Private Sub btn57_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn57.Click

btn57.Enabled = False

End Sub

Private Sub btn58_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn58.Click

btn58.Enabled = False

End Sub

Private Sub btn59_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn59.Click

btn59.Enabled = False

End Sub

Private Sub btn60_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn60.Click

btn60.Enabled = False

End Sub

Private Sub btn61_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn61.Click

btn61.Enabled = False

End Sub

Private Sub btn62_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn62.Click

btn62.Enabled = False

End Sub

Private Sub btn63_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn63.Click

btn63.Enabled = False

End Sub

Private Sub btn64_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn64.Click

btn64.Enabled = False

End Sub

Private Sub btn65_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn65.Click

btn65.Enabled = False

End Sub

Private Sub btn66_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn66.Click

btn66.Enabled = False

End Sub

Private Sub btn67_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn67.Click

btn67.Enabled = False

End Sub

Private Sub btn68_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn68.Click

btn68.Enabled = False

End Sub

Private Sub btn69_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn69.Click

btn69.Enabled = False

End Sub

Private Sub btn70_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn70.Click

btn70.Enabled = False

End Sub

Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged

End Sub
End Class
```

Sunday, September 30, 2012 4:27 PM

### All replies

• esse projeto é jogo em vb que o usuario escolhe sei numero e depois aperta o botao jogar.Dai faz o sorteio .esse sistema tem 70 botoes de 1 a 70.qual a logica uasada para que quando eu tiver clickado em seis botoes ele ele disabilitem os outros botoes,pois´só pode apostar em 6 numeros?

e depois comparar os numeros sorteados que estao no listbox1 com listbox3,se os seis numeros sorteios forem iguias os apostados trazer uma mensagem "PARABENS!!!VOCÊ É O NOVO GANHAR "

Obs.:Esse jogo é como se fosse o jogo da mega sena

E tambem nao pode sortear dois numeros iguais dai eu usei esse codigo

``` Private Sub btnjogar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnjogar.Click
tmrSorteio.Enabled = True
If a = b Or b = c Or c = d Or f = g Or a = c Or a = d Or a = f Or a = g Or b = d Or b = f Or b = g Or c = f Or c - g Or d = g Or f = g Or c = f Then
tmrSorteio.Enabled = True

End If
btnjogar.Enabled = False

End Sub```

Sunday, September 30, 2012 5:34 PM
• esse jogo é como se fosse o jogo da mega sena .

Eu queria saber como eu faço a comparação do listbox1 com o listbox3 para que se tiver os "6" numeros apostados iguais trazer na tela "Voce é o novo ganhador"

nesse jogo tem 70 botoes onde o jogar tem que escolher apenas 6 numeros.Como eu faço para que quando escolher os seis numeros deslabilitar todos o botoes,para que ele não possa escolher outro numero ?

E depois eu queria o meu jogo tivesse um botao com o nome novo jogo ele exclui todos numeros  dos listbox com apenas um click ,para iniciar um novo jogo?

E nesse jogo não pode ser sorteado dois numeros iguais ,como resolver isso?

``` Private Sub btnjogar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnjogar.Click
tmrSorteio.Enabled = True
If a = b Or b = c Or c = d Or f = g Or a = c Or a = d Or a = f Or a = g Or b = d Or b = f Or b = g Or c = f Or c - g Or d = g Or f = g Or c = f Then
tmrSorteio.Enabled = True

End If
btnjogar.Enabled = False

End Sub```

eu usei esse codigo mas nao esta funcionado.

Fico no aguardo Obrigado

Sunday, September 30, 2012 6:19 PM
• Campeão, este fórum é destinado a C#, e não vb.net. Segue fórum onde pode te ajudar mais: