Not to step on anyone, but in reference to this thread on summing odds and evens, why not just use the 'continue' statement? So adding up the odds would look something like this:
-on some event- - Dim counter, sum As Short
-
sum = 0
-
For counter = 1 To 99
-
If counter Mod 2 = 0 Then Continue For
-
sum += counter
-
Next
-
lblOdd.Text = sum
-
end sub
You would just have to define the array from an input.
8 2323
Not to step on anyone, but in reference to this thread on summing odds and evens, why not just use the 'continue' statement?
Visual Basic has a continue statement? That's news to me. What version of VB?
Visual Basic has a continue statement? That's news to me. What version of VB?
VB 2005 is the first ver. to incorporate it (that I know of).
VB 2005 is the first ver. to incorporate it (that I know of).
So, I'm guessing that it skips to the next iteration of the loop?
The language I use on the mainframe, called Natural, has such a statement (ESCAPE TOP). This has always been one of its best features, and one which I have greatly missed in other languages.
To get back to the original question (not that the poster will see any of this, I suppose)...
If anyone's interested, it seems to me that just about the most efficient method (assuming there isn't a way to do it in a single calculation) would be to use an IF/ELSE construct. For example: - Dim Counter As Long, SumOdd As Long, SumEven As Long
-
For Counter = 1 To 99
-
If Counter Mod 2 Then
-
SumOdd = SumOdd + Counter
-
Else
-
SumEven = SumEven + Counter
-
End If
-
Next
(I'm assuming that the real issue wasn't about a simple 1 to 99 loop.)
Here's the list of new commands.
From M$:
"Continue Statement
Visual Basic now supplies a Continue statement, which immediately skips to the next iteration of a Do, For, or While loop. "
And no, my problem was much more difficult. I just don't expect more experienced people to do my homework for me :) (though, answering a question here and there has been invaluable).
Here's the list of new commands.
Thanks, I'll bookmark that one for (probably a lot of) future reference.
And no, my problem was much more difficult. I just don't expect more experienced people to do my homework for me :) (though, answering a question here and there has been invaluable).
Uh oh... you said the "H word". Now I'll have to close down the thread and kill you. ;)
In case this is too cryptic, I should point out that there has been considerable (and sometimes heated) heated debate over the handling of homework & coursework questions on TheScripts.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Yaroslav Bulatov |
last post by:
I made an array of 10 million floats timed how long it takes to sum
the elements, here's what I got (millis):
gcc -O2: 21
Python with numarray: 104
Python with Numeric: 302...
|
by: SunMan |
last post by:
Hello!
I am trying to create a program that will ask for a user to enter a series of letters (codes) and then print out a table that shows the codes in decending frequency. Only letters will be...
|
by: Targa |
last post by:
<input NAME="TAXRATE" onBlur="this.form.TAX.value =
(this.form.TAXRATE.value - 0) * (this.form.ITEM1TOTAL.value - 0) +
(this.form.ITEM2TOTAL.value - 0) " Size="4">
In my TAX field I get...
|
by: Hank |
last post by:
I have a report-summing problem using Access 2000. When a section runs
over the end of the page, sometimes a detail gets picked up twice.
Example:
Customer Header
XYZ Company
Detail Section...
|
by: siva prasad |
last post by:
hello,
i have an appplication in which when i click a button
then all the odds in a website are to be displayed. so i
need Regular Expressions for identifing the odds.i am in
the learner stage of...
|
by: Mamatha |
last post by:
Hi
I want to write regular expression for odds which related
to sports in VB.NET.
But i don't know how to write regular expression for odds.
If anyone knows the solution or any related urls...
|
by: MrL8Knight |
last post by:
I am building a simple shopping cart and I am having problems trying to add the costs of the items to generate a total cost. I am new at this so forgive me if my technical verbiage isn’t the...
|
by: neeraj |
last post by:
Hi
Can any body give me the syntax for summing the elements of the an
array , without looping
thanks
|
by: lethek39 |
last post by:
Hey
I have been trying to figure out how to sum rows and columns in a matrix square. I also have been trying to get the program to list the numbers of the diagonal in the matrix. So far this is the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |