|
-
Aug 2nd, 2008, 02:13 AM
#1
Thread Starter
New Member
-
Aug 2nd, 2008, 04:05 PM
#2
Re: generate numbers
Can you edit your post and use [code] tags to display the code and indent it (if not indented yet) please? This is to hard to read.
-
Aug 2nd, 2008, 04:58 PM
#3
Re: generate numbers
Alright, the problem is that the module is not accessing the form, but the local variables.
What you have to do is
- Remove all "On Error Resume Next" lines, because they make it harder to find errors in the code if they are in there
- In the module remove every "Dim Text1"
- Replace "Text1" in the module with "int(Form1.Text1.Text)"
- In checkifexists use a new variable for the loop
Example of the things above:
(RED = to remove)
(ORANGE = to edit)
Code:
Private Function checkifexists(number As Integer) As Boolean
On Error Resume Next
Dim v1 As Integer
For v1 = 1 To numberofnumbers + 1
If number = uniqueseq(int(Form1.Text1.Text)) Then
checkifexists = False
Exit Function
End If
Next v1
checkifexists = True
End Function
So at least remove all "On Error Resume Next" lines and if it still doesn't work, post the error you get.
Delete it. They just clutter threads anyway.
-
Aug 3rd, 2008, 09:43 AM
#4
Re: generate numbers
One thing for sure, you can prrobably replace this chunk of your code:
Code:
Do
Randomgen = Int((numberofnumbers + 1) * Rnd)
Loop Until Randomgen <> 0
with this
Code:
RandomGen = Int(Rnd * numberofnumbers + 1)
In your code, if numberofnumbers somehow reaches 0 or -1, your code will hang forever. My suggested code will produce 0 only if numberofnumbers reaches -1 and it will never hang.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|