|
-
May 2nd, 2000, 08:59 AM
#1
Thread Starter
Addicted Member
ok.. there is a loop..
It looks just dandy to me..
Whats the problem it??
ALL the code..
------------------------
Dim RndNum As Integer
Dim RecordRndNum(200) As Integer
Dim KeepRecordPlace As Integer
Dim Matches As Integer
Dim looper As Integer
Startover:
Randomize
RndNum = Int(Rnd * 84) + 1
RecordRndNum(KeepRecordPlace) = RndNum
KeepRecordPlace = KeepRecordPlace + 1
Do While looper <= 200
If RndNum = RecordRndNum(looper) Then
Matches = Matches + 1
End If
looper = looper + 1
Loop
If Matches > 1 Then
KeepRecordPlace = KeepRecordPlace - 1
Matches = 0
GoTo Startover
End If
Counter = RndNum
-------------------------------------------
-
May 2nd, 2000, 09:16 AM
#2
Addicted Member
Goto!!
Goto!!!
GOTO!!!!
ahhhhhhhhhhh!!!!!!!!
Run away!!!
Dan PM
Analyst Programmer
VB6 SP3 (also VB4 16-bit sometimes  )
-
May 2nd, 2000, 12:39 PM
#3
Thread Starter
Addicted Member
-
May 2nd, 2000, 12:43 PM
#4
Thread Starter
Addicted Member
What do I write to make it go back to the
Original place 'startover'????
-
May 2nd, 2000, 04:42 PM
#5
Fanatic Member
You're a braver man than me, posting a goto liek that on this forum. Everyone seems to hate it with a passion.
Also i can't see where you set looper back to zero any where in the loop.
Code:
Dim RndNum As Integer
Dim RecordRndNum(200) As Integer
Dim KeepRecordPlace As Integer
Dim Matches As Integer
Dim looper As Integer
While Matches <> 1
Matches = 0
Randomize
RndNum = Int(Rnd * 84) + 1
RecordRndNum(KeepRecordPlace) = RndNum
KeepRecordPlace = KeepRecordPlace + 1
Do While looper <= 200
If RndNum = RecordRndNum(looper) Then
Matches = Matches + 1
End If
looper = looper + 1
Loop
If Matches > 1 Then
KeepRecordPlace = KeepRecordPlace - 1
End If
Wend
Counter = RndNum
Iain, thats with an i by the way!
-
May 2nd, 2000, 05:59 PM
#6
Conquistador
why do you want it to startover again?
-
May 2nd, 2000, 09:12 PM
#7
What are you trying to accomplish? Do you want a list of 84 unique random numbers? Something else?
-
May 4th, 2000, 03:08 PM
#8
Conquistador
i hate the randomize function,
when i was writing a little program, it was a pain in the arse
-
May 4th, 2000, 05:21 PM
#9
Addicted Member
Goto
I just wonder why everybody seems to be so upset about Goto?
Ok, I knowe it makes the code hard tu understand, maintain and change, but sometimes it's just the easiest way to solve a problem.
Maybe only the brave dare to use Goto?
And btw, we all use On Error Goto, don't we?
What's the difference between that and other Goto:s?
If Angry, Do Not Goto Pentax.
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
May 4th, 2000, 07:19 PM
#10
Conquistador
because it is annoying, and it does not always do what you want
-
May 4th, 2000, 07:36 PM
#11
transcendental analytic
GOTO
Goto have been pretty useless since i programmed in gwbasic, but there can be handy in Exiting more than one loop
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 5th, 2000, 01:00 AM
#12
Addicted Member
Try programming in Assembly and you'll quickly understand why Goto is looked down upon so much. One little change and your entire logic structure is blown to sh!†, plus it's confusing and completely un-necessary in VB! Everything that needs to be accomplished with Gotos can be re-written using stronger logic and better planning. You can use loops, switches, flag variables, functions/subs, and recursion (not the best alternative). Just sit and do some Flow Charts, Data Diagrams, and Desk Checks before you start plugging away at your code. You'll appreciate this advice so much more when you come back to this app in a few years and try to understand what the hell you were smoking when you wrote it, and trust me, you will come back to it eventually if it was worth your time to write.
Dan PM
Analyst Programmer
VB6 SP3 (also VB4 16-bit sometimes  )
-
May 5th, 2000, 02:31 AM
#13
Thread Starter
Addicted Member
Thanks Guys!!
You know what.. Acutally I fingured out
what was wrong.. I learned something
valuable. NEVER NAME YOUR FUNCTION RANDOMIZE.
lol.. I must have been out of my mind!!
Did you guys know that if you name your
function after a call in vb your program
goes nuts?
-
May 5th, 2000, 10:14 AM
#14
Conquistador
you can always use exit do 
for exit for
if you are using those loops
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
|