Hej i am trying to create a simple game as homework from my school. now i just stuck on one stage.
see the picture on this link how it looks like.
http://jobbalert.se/
i have created a module here is the code for module file
Module Module1
Public Sub bknapper()
'create button on fly
Dim intLoop As Integer
Dim rand As New Random
'genrate array that will get the random values from c variable and
'will use to compare if the value is unique
Dim kontroll(49) As Integer
' Off sets
Dim y As Integer = 65
Dim x As Integer = 0
Dim a, b, c, d, e1 As Integer
a = 1
b = 10
' Loop through buttons
For intLoop = 0 To 24
' Create button and set its width
Dim newbutton As New CheckBox
newbutton.Appearance = Appearance.Button
newbutton.TextAlign = ContentAlignment.MiddleCenter
newbutton.Width = 40
newbutton.Height = 40
' If we have hit 4 buttons, adjust the y value by adding 10 onto the controls height
' Reset x back to 0
If intLoop Mod 5 = 0 Then
' This gives us a 10 pixel buffer below each row of buttons
y += newbutton.Height + 1
x = 0
End If
' give random value rage
'first line will show random values between 1 and 10
'second line will show random values between 10 and 20
'and so on
Select Case intLoop
Case 5
a += 10
b += 10
Case 10
a += 10
b += 10
Case 15
a += 10
b += 10
Case 20
a += 10
b += 10
Case 25
a += 10
b += 10
End Select
'genrate random values and save that value in variable c
c = rand.Next(a, b)
newbutton.Text = c
'check if the randomize value is unique if not give that another random value and check it again
For d = 0 To 49
If kontroll(d) = c Then
c = rand.Next(a, b)
newbutton.Text = c
Else
Dim d1 As Integer
For d1 = 0 To 49
If kontroll(d1) = c Then
c = rand.Next(a, b)
newbutton.Text = c
End If
Next
End If
Next d
'assgin all random c variable values to an array of integer "kontroll"
kontroll(intLoop) = c
newbutton.Top = y
' This gives us a 5 pixel right buffer between buttons
newbutton.Left = 350 + (x * (newbutton.Width + 1))
x += 1
Form1.Controls.Add(newbutton)
Next
End Sub
End Module
and what i want when i press the button on form1 it will reload and show new random numbers on that buttons and code for form 1 is here
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
bknapper()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form2.Show()
End Sub
Private Sub AvslutaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AvslutaToolStripMenuItem.Click
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form1_Load(Me, New System.EventArgs)
End Sub
End Class
can any one help me.. or tell me the logic what i am doing wrong.