supermadin
09-06-2007, 02:04 AM
hi it's me again...
i created a random number generator with the help of matt and others... well i want to experiment..
what i want now is that.. when i generate a random generator after that search the winning number from diffirent worksheet to find out if someone won?
can you please help me?
here is the code of my generator
Option Explicit
Private Sub CommandButton1_Click()
Dim vTime As Date, vNumber As String, i As Long, j As Long, k As Long
UserForm1.TextBox5.Visible = False
UserForm1.Label3.Visible = False
Randomize
vNumber = Format(Int(Rnd * 1629 + 1), "0000")
For i = 1 To 4
vTime = Now
Do Until Now > vTime + TimeValue("00:00:01")
Randomize
If i = 1 Then
TextBox1.Text = CStr(Int(Rnd * 2))
k = 2
Else
k = i
End If
For j = k To 4
Me.Controls("TextBox" & CStr(j)).Text = CStr(Int(Rnd * 10))
Next
DoEvents
Loop
Me.Controls("TextBox" & CStr(i)).Text = Mid(vNumber, i, 1)
Next
UserForm1.TextBox5.Visible = True
UserForm1.Label3.Visible = True
Sheet1.Cells(Rows.Count, "A").End(xlUp)(2, 1) = TextBox1.Text
Sheet1.Cells(Rows.Count, "B").End(xlUp)(2, 1) = TextBox2.Text
Sheet1.Cells(Rows.Count, "C").End(xlUp)(2, 1) = TextBox3.Text
Sheet1.Cells(Rows.Count, "D").End(xlUp)(2, 1) = TextBox4.Text
Sheet1.Cells(Rows.Count, "D").End(xlUp).Offset(0, 1).Value = TextBox5.Text
TextBox5 = ""
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub Label3_Click()
End Sub
Private Sub TextBox5_Change()
Sheet1.Cells(Rows.Count, "D").End(xlUp).Offset(0, 1).Value = TextBox5.Text
End Sub
Private Sub UserForm_Initialize()
Call RemoveCaption(Me)
End Sub
thanks waiting for someone to help me: pray2:
i created a random number generator with the help of matt and others... well i want to experiment..
what i want now is that.. when i generate a random generator after that search the winning number from diffirent worksheet to find out if someone won?
can you please help me?
here is the code of my generator
Option Explicit
Private Sub CommandButton1_Click()
Dim vTime As Date, vNumber As String, i As Long, j As Long, k As Long
UserForm1.TextBox5.Visible = False
UserForm1.Label3.Visible = False
Randomize
vNumber = Format(Int(Rnd * 1629 + 1), "0000")
For i = 1 To 4
vTime = Now
Do Until Now > vTime + TimeValue("00:00:01")
Randomize
If i = 1 Then
TextBox1.Text = CStr(Int(Rnd * 2))
k = 2
Else
k = i
End If
For j = k To 4
Me.Controls("TextBox" & CStr(j)).Text = CStr(Int(Rnd * 10))
Next
DoEvents
Loop
Me.Controls("TextBox" & CStr(i)).Text = Mid(vNumber, i, 1)
Next
UserForm1.TextBox5.Visible = True
UserForm1.Label3.Visible = True
Sheet1.Cells(Rows.Count, "A").End(xlUp)(2, 1) = TextBox1.Text
Sheet1.Cells(Rows.Count, "B").End(xlUp)(2, 1) = TextBox2.Text
Sheet1.Cells(Rows.Count, "C").End(xlUp)(2, 1) = TextBox3.Text
Sheet1.Cells(Rows.Count, "D").End(xlUp)(2, 1) = TextBox4.Text
Sheet1.Cells(Rows.Count, "D").End(xlUp).Offset(0, 1).Value = TextBox5.Text
TextBox5 = ""
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub Label3_Click()
End Sub
Private Sub TextBox5_Change()
Sheet1.Cells(Rows.Count, "D").End(xlUp).Offset(0, 1).Value = TextBox5.Text
End Sub
Private Sub UserForm_Initialize()
Call RemoveCaption(Me)
End Sub
thanks waiting for someone to help me: pray2: