From: NeatBoxx via VBMonster.com on 17 Jul 2010 10:09 Kevin Provance wrote: >: The main problem is that my algorithm is not very efficient and cause'es >: program crashes. I don't have the expertise to do things in programming that >: others find easy...Just too old...I guess. I would appreicate any help. >: Just copy and paste the code into Visual Basic 6 and read the instuctions and >: you will see what I am trying to do. > >What do you mean by crashes? Does VB actually crash and close? Does an >error message appear? If so, what does it say? > >The only crash I have experience thus far is attempting to exit the program >in mid loop, which is easily fixed with a cancel button and a global boolean >value to stop the loop. > >Any additional info about the crashes would be helpful > >- Kev *********************************************************************************** In regard to the crashes...When I try to use a larger set such as P = (18,24). ..this should produce a matrix of 24 combinations with each number appearing exactly 18 times. It will run and run, but after a while the form turns white and the hourglass comes up I have to hit control break to get the program to stop...I have never seen it do this until this module...Have any ideas as to what would cause that -- Message posted via VBMonster.com http://www.vbmonster.com/Uwe/Forums.aspx/vb/201007/1
From: NeatBoxx via VBMonster.com on 17 Jul 2010 10:59 Michael Cole wrote: >NeatBoxx via VBMonster.com has brought this to us : >> Hi, Fellow Coders of Visual Basic 6 > >Comments inline > >> If anyone can or will help; I have included my code that I have so far...It >> works but very inefficiently. > >I'll have a go. > >> The main problem is that my algorithm is not very efficient and cause's >> program crashes. > >What the hell is the algorithm supposed to accomplish? I have fixed >what I can, but I still don't know what the outcome should be. > >Some minor coding points are below, but I really need an answer to the >above question to go any further. > >> Private Sub Command1_Click() >> Randomize Timer > >Stick this in the form load event, not in the command click event. it >should only ever be called once. > >> Dim v, x, y, z, t, u, w, q, j, Field, Elements, Frequency, Combinations, >> Kcount, Sets As Long > >See Kevin's comments about variable declaration. Also, convert all >these (q-z) into an array of long - i.e., > >Dim lngOccurrances(0 To 7) As Long > >_________________________________________ >> ' Parameters = (Frequency,Combinations)= P = (f,c) >> 'Where f = The Exact Number Of Times Each Number Appears In a (f,c) Matrix >[quoted text clipped - 7 lines] >> '** Each Result Will Be Different >> '** And Each Number 1 - 8 Will Appear Exactly 3 Times > >This (above explanation) is what I don't understand... > >> Do While _ >> v <> Frequency Or _ >[quoted text clipped - 6 lines] >> q <> Frequency >> > > Do While True > > For j = 0 To UBound(lngOccurrances) > If lngOccurrances(j) = Frequency Then > Exit Do > End If > Next j > >[SNIP] > >> >> If j = 1 Then v = v + 1 'Counts The Number Of Times J = 1 >[quoted text clipped - 5 lines] >> If j = 7 Then w = w + 1 ' >> If j = 8 Then q = q + 1 'Counts The Number Of Times J = 8 > > lngOccurrances(j - 1) = lngOccurrances(j - 1) + 1 ****************************************************************************8 Michael The algorithm is supposed to generate lotto combinations in sets of 4,8,12, 16,20,24,28 there are only 7 unique ways this can happen using the number 8. For example using 4 the program will generate 4 lotto combinations of 6 numbers in each combination. Notice that each number appears exactly 3 times. this is the core of my idea... 1-2-3-5-6-7 1-2-4-5-6-8 1-3-4-5-7-8 2-3-4-6-7-8 When the module is working right I will be able to generate the following scenarios! (3,4).......4 combinations with each number appearing exactly 3 times (6,8).......8 combinations with each number appearing exactly 6 times Up to (21,28) with each number appearing exactly 21 times These scenarios must be generated randomly because there many variations of the same scenarios. The example above if the lotto numbers drawn were 1-2-3-4-5-6 I would win at least 1 5 of 6 prize which is $600.00 in my state game. Of course I would never use the numbers I am showing here because they are not practical...I would have to substitute .....1= 7.....2 = 14 3= 17 4= 20 5=23 6= 32 7= 36 8 = 41 the first line in the above example would become 7-14-17-23-32-36 I hope this clears up to what I am trying to accomplish...Thank you so much for your input -- Message posted via VBMonster.com http://www.vbmonster.com/Uwe/Forums.aspx/vb/201007/1
From: Kevin Provance on 17 Jul 2010 11:36 "NeatBoxx via VBMonster.com" <u61568(a)uwe> wrote in message news:ab233d4132787(a)uwe... : Kevin Provance wrote: : >: The main problem is that my algorithm is not very efficient and cause'es : >: program crashes. I don't have the expertise to do things in programming that : >: others find easy...Just too old...I guess. I would appreicate any help. : >: Just copy and paste the code into Visual Basic 6 and read the instuctions and : >: you will see what I am trying to do. : > : >What do you mean by crashes? Does VB actually crash and close? Does an : >error message appear? If so, what does it say? : > : >The only crash I have experience thus far is attempting to exit the program : >in mid loop, which is easily fixed with a cancel button and a global boolean : >value to stop the loop. : > : >Any additional info about the crashes would be helpful : > : >- Kev : *********************************************************************************** : : In regard to the crashes...When I try to use a larger set such as P = (18,24). : .this should produce a matrix of 24 combinations with each number appearing : exactly 18 times. It will run and run, but after a while the form turns : white and the hourglass comes up I have to hit control break to get the : program to stop...I have never seen it do this until this module...Have any : ideas as to what would cause that Ah, I foxed that by sticking a DoEvents right after the last For/Next loop. No freezes. :-)
From: NeatBoxx via VBMonster.com on 17 Jul 2010 13:38 Michael Cole wrote: >NeatBoxx via VBMonster.com has brought this to us : >> Hi, Fellow Coders of Visual Basic 6 > >Comments inline > >> If anyone can or will help; I have included my code that I have so far...It >> works but very inefficiently. > >I'll have a go. > >> The main problem is that my algorithm is not very efficient and cause's >> program crashes. > >What the hell is the algorithm supposed to accomplish? I have fixed >what I can, but I still don't know what the outcome should be. > >Some minor coding points are below, but I really need an answer to the >above question to go any further. > >> Private Sub Command1_Click() >> Randomize Timer > >Stick this in the form load event, not in the command click event. it >should only ever be called once. > >> Dim v, x, y, z, t, u, w, q, j, Field, Elements, Frequency, Combinations, >> Kcount, Sets As Long > >See Kevin's comments about variable declaration. Also, convert all >these (q-z) into an array of long - i.e., > >Dim lngOccurrances(0 To 7) As Long > >_________________________________________ >> ' Parameters = (Frequency,Combinations)= P = (f,c) >> 'Where f = The Exact Number Of Times Each Number Appears In a (f,c) Matrix >[quoted text clipped - 7 lines] >> '** Each Result Will Be Different >> '** And Each Number 1 - 8 Will Appear Exactly 3 Times > >This (above explanation) is what I don't understand... > >> Do While _ >> v <> Frequency Or _ >[quoted text clipped - 6 lines] >> q <> Frequency >> > > Do While True > > For j = 0 To UBound(lngOccurrances) > If lngOccurrances(j) = Frequency Then > Exit Do > End If > Next j > >[SNIP] > >> >> If j = 1 Then v = v + 1 'Counts The Number Of Times J = 1 >[quoted text clipped - 5 lines] >> If j = 7 Then w = w + 1 ' >> If j = 8 Then q = q + 1 'Counts The Number Of Times J = 8 > > lngOccurrances(j - 1) = lngOccurrances(j - 1) + 1 **************************************************************************************** Michael I fixed the first 2 suggestions, but as far as the array part I am lost... don't have a clue how to implement that in my code. Could you please incorporate that into my code so that I can actually study it. Arrays have alway troubled me...I think mostly because of my mild dyslexia....Hard to think in more than 1 dimension -- Message posted via http://www.vbmonster.com
From: Michael Cole on 18 Jul 2010 08:28
NeatBoxx via VBMonster.com explained on 18/07/2010 : > Michael > > The algorithm is supposed to generate lotto combinations in sets of > 4,8,12, 16,20,24,28 there are only 7 unique ways ... [SNIP] > The example above if the lotto numbers drawn were 1-2-3-4-5-6 I would win at > least 1 5 of 6 prize which is $600.00 in my state game. Of course I would > never use the numbers I am showing here because they are not practical...I > would have to substitute .....1= 7.....2 = 14 3= 17 4= 20 5=23 6= 32 > 7= 36 8 = 41 > > the first line in the above example would become 7-14-17-23-32-36 > > I hope this clears up to what I am trying to accomplish...Thank you so much > for your input OK. This I have to respond to first, even though it is nothing to do with coding. My area of study is statistics, and as it looks as if you are trying to create a lotto-winning scheme, let me tell you that there is no such thing. There is _no_ winning system, and no amount of random number generation will ever change that. Lotto is not about random numbers, it is about statistics. If you can tell me what you want, then a calculation can be written which will give the numbers you want without any need for any random number generation. Sorry to be so harsh, but what you are working on is pointless. I can tell this from your statement that, "Of course I would never use the numbers I am showing here because they are not practical..." Sorry to disappoint you, but the numbers 1, 2, 3, 4, 5 and 6 are _exactly_ as practical as 7, 14, 17, 23, 32 and 36. There is _absolutely no difference between the two sets_, and no system for picking individual combinations will ever increase your chance of winning. Apologies for the harshness. If you want, I can post back completed code regarding the arrays simply so that you can see what I was doing - let me know if you would like this done - but I will not be doing any more work on the actual code. If you can state what you are wanting to accomplish at the end, then I could provide calculations as to your chance of winning, but nothing as to what numbers to try - any combination is the same as any other. |