Dear Friends,
as my logic synapses aparently having gone on holidays, I'm stuck with 2 issues.
First:
With a For/Next loop like
For i = ListBox1.count - 1 DownTo ListBox1.count - 180
I want with ValueBoxes labeled START and END to have the user define the ListBox.Count Start-and End-Numbers. I tried to replace -1 and -180 with Integer variables - like:
For i = ListBox1.count - START DownTo ListBox1.count - END
or - leave the loop alone, if the ValueBoxes are "" or empty ...
I got nowhere ... String-Variables also not accepted.
********************************************************
Second:
While the For/Next loop is running through the items of Listbox1 (a list - about 200 items - of Numbers from 0 to 36), it produces "loss" or "win" and a "balance" all of thouse listed in further ListBoxes regarding to thier variables:
loss
totloss
win
totalwin
balance
Works pretty well and matches manual test/control on a spread sheet.
Now I want to catch the trends - as it does not make sense to further bet on a down trend unless a upward trend appears again.
I got around it by limiting betting to 6 or 9 loops/coups. It would be smart, if bets only start after 3 consecutive wins or are not further done after 3 consecutive (excuse spelling) losses.
******************************************************
I'm attaching a screenshot but also could add the code for further understanding (if you prefer some entertainment with my humptydumpty coding).
Would appreciate some hints. Your hints with a previous issue where excellent ...
Well and Third:
How do I leave a FOR/NEXT loop if a condition is reached whithout closing the application? Stop und Exit ? or just Form1.Show? ....
Klaus
FOR/NEXT loop with variables/ solved!
-
- Posts: 8
- Joined: Thursday 24th February 2022 12:18pm
FOR/NEXT loop with variables/ solved!
- Attachments
-
- gambas-start.png (80.34 KiB) Viewed 2450 times
Last edited by pentilisea on Thursday 17th March 2022 9:36am, edited 2 times in total.
Re: FOR/NEXT loop with variables
START.Value ... END.Value ???
-
- Posts: 8
- Joined: Thursday 24th February 2022 12:18pm
Re: FOR/NEXT loop with variables
Hi,
START and END values are set by user via 2 ValueBoxes. The Count of ListBox1 is displayed and normally between 150 and 250 items in the list. So, the user wants run a test via button TWO-UP say from 100 to 150, so 100 would be entered in Valuebox START und 150 in ValueBox END.
Important to know that the Numbers/Items in ListBox1 are counted from last Item. Last number (count -1) is displayed and if the bet is = the number (count-2) following Last number, called Prenumber, then a win of 35 is added, last number deleted from list and Prenumber becomes Last number.
So the value of START =100 will represent ListBox1.Count - 100 and END = 150 ListBox1.Count -150 ....
My problem ist how to assign 2 variables START and END and getting thier values into the FOR/NEXT loop.
For i = ListBox1.count - 1 DownTo ListBox1.count - 180
so count-1 would be replaced with count -100 and count -180 would be replaced with count-150 ....
START and END values are set by user via 2 ValueBoxes. The Count of ListBox1 is displayed and normally between 150 and 250 items in the list. So, the user wants run a test via button TWO-UP say from 100 to 150, so 100 would be entered in Valuebox START und 150 in ValueBox END.
Important to know that the Numbers/Items in ListBox1 are counted from last Item. Last number (count -1) is displayed and if the bet is = the number (count-2) following Last number, called Prenumber, then a win of 35 is added, last number deleted from list and Prenumber becomes Last number.
So the value of START =100 will represent ListBox1.Count - 100 and END = 150 ListBox1.Count -150 ....
My problem ist how to assign 2 variables START and END and getting thier values into the FOR/NEXT loop.
For i = ListBox1.count - 1 DownTo ListBox1.count - 180
so count-1 would be replaced with count -100 and count -180 would be replaced with count-150 ....
- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: FOR/NEXT loop with variables
We may need to see the code to fully understand what you are trying to do. Anyway, here is my response:-
Have a look at this code: -First:
With a For/Next loop like
For i = ListBox1.count - 1 DownTo ListBox1.count - 180
Consider using arrays to store the data. An Integer array could hold ID, Total Wins, Total losses: - IDArray = [24, 2, 3]Second:
While the For/Next loop is running through the items of Listbox1 (a list - about 200 items - of Numbers from 0 to 36), it produces "loss" or "win" and a "balance" all of thouse listed in further ListBoxes regarding to thier variables:
You can use Exit to leave a For Next loop at any time. Consider the following code: -Well and Third:
How do I leave a FOR/NEXT loop if a condition is reached whithout closing the application? Stop und Exit ? or just Form1.Show? ....
For iLoop = 0 To 20
If iLoop = 5 Then Exit
Next
Print iLoop
The loop will only ever get to 5 and the Print statement will print 5.-
- Posts: 8
- Joined: Thursday 24th February 2022 12:18pm
Re: FOR/NEXT loop with variables
Dear Cogler,
as always thanks so much for the spot on help. Often I'm spinning around the correct solution and simply not getting the syntax right.
Well, keeing trying and inching foreward .....
as always thanks so much for the spot on help. Often I'm spinning around the correct solution and simply not getting the syntax right.
Well, keeing trying and inching foreward .....