473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Simple For..Next query

Hi all. I am trying to write some code for a "Lotto" program (hey its a bit
of fun) It creates 3 profiles of numbers and extrapolates a full 36 game
card from them.

On the 3rd profile ask's a question like "please enter a number between 15
and 36, but one that has NOT been used in Profile 1 or 2".

Then I wanted to offer some suggestions in a statusbar. I tried running a
for next loop starting at 15 and finishing at 36 steping 1 at time and
displaying the result in the status bar. HOWEVER I wanted to exclude any
numbers that had already been provided in the previous profiles.

I have listed the code below but keep getting errors as I have a Next
without for command. How can I re-write it so it works.

Also, how can I get the numbers to appear next to each other along the
Status Bar without having to assign them to a new bar each time. I vaguely
remember being able to put a semi colon (;) at the end of a statement to
indicate that the next number should append to there, but this doesnt work
in .net.

THANKS IN ADVANCE.

For iCounter = 15 To 36 Step 1

Select Case iCounter

case = iFirstNumber Or iSecondNumber Or iThirdNumber Or iFourthNumber Or
iFifthNumber Or iSixthNumber Then

next icounter

Case Else

iSuggestion = iCounter

StatusBar1.Text = iSuggestion;

End Select

Next iCounter
Oct 11 '05 #1
1 1268
Try loading the numbers into a hashtable:

ht.Add(thisNumber, null)

You can then check to see if the number exists already:

If Not ht.Exists(thisNumber) Then
ht.Add(thisNumber, null)
End If

If ht.Count = 6 Then
'You now have your numbers, so start next set of numbers
End If

You can also use a sorted list, if you want the numbers to be sorted from
lowest to highest.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Bails" wrote:
Hi all. I am trying to write some code for a "Lotto" program (hey its a bit
of fun) It creates 3 profiles of numbers and extrapolates a full 36 game
card from them.

On the 3rd profile ask's a question like "please enter a number between 15
and 36, but one that has NOT been used in Profile 1 or 2".

Then I wanted to offer some suggestions in a statusbar. I tried running a
for next loop starting at 15 and finishing at 36 steping 1 at time and
displaying the result in the status bar. HOWEVER I wanted to exclude any
numbers that had already been provided in the previous profiles.

I have listed the code below but keep getting errors as I have a Next
without for command. How can I re-write it so it works.

Also, how can I get the numbers to appear next to each other along the
Status Bar without having to assign them to a new bar each time. I vaguely
remember being able to put a semi colon (;) at the end of a statement to
indicate that the next number should append to there, but this doesnt work
in .net.

THANKS IN ADVANCE.

For iCounter = 15 To 36 Step 1

Select Case iCounter

case = iFirstNumber Or iSecondNumber Or iThirdNumber Or iFourthNumber Or
iFifthNumber Or iSixthNumber Then

next icounter

Case Else

iSuggestion = iCounter

StatusBar1.Text = iSuggestion;

End Select

Next iCounter

Oct 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Leroy | last post by:
I really need some help with showing pages of results from queries in say like groups of 20 with next and previous buttons or links. I'm having a lot of trouble figuring out the logic of such a...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
6
by: Eddie Smit | last post by:
field- field- surname town ---- ---- john NY john Vegas john Boston eddie Boston eddie New Orleans eddie NY
5
by: deko | last post by:
I use a For Each... Next loop like this: For Each varFnm In Array("This", "That", "OtherThing", "Foo", "Bar") RunSql ("UPDATE.... bla bla bla) Next But the exact same elements of the Array...
1
by: Lloyd Stevens | last post by:
CustomerTable CustomerTarrifTable TarrifTable WarrantTable *CustomerID CustomerID ProductName *WarrantID BoatType *CustomerTarrifID TarrifRate WarrantDate CustomerName ...
15
by: Richard Hollenbeck | last post by:
For example, one college course has only 24 students in it, but the following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs. When it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and...
0
by: Freebase | last post by:
Something changed recently on our W2K SP4 machine when we installed INTERSOLV ODBC software... the following script just opens a connection to an MS-Access DB, gets a record then tears down the...
14
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ;...
3
by: John Baker | last post by:
Hi:7 Newby here to ASP, and using the ASP.NET Web Matrix development tool. While that tool looks great for a Newby, I have run into a snag. I have an HTML Text Box which I have named HireInput,...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.