473,581 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with parameter not passed from for loop to while loop

Hi,

I'm trying to pass a parameter from a for loop to the nested while loop
but only the first counter is passed. Here is the code:

dim ctr
redim ctr(5)
ctr(0) = 2
ctr(1) = 4
ctr(2) = 6
ctr(3) = 8
ctr(4) = 10
ctr(5) = 12
dim counter
redim counter(5)
counter(0) = 0
counter(1) = 2
counter(2) = 2
counter(3) = 3
counter(4) = 4
counter(5) = 5

dim ctsum1
redim ctsum1(100)
dim ctsum2
redim ctsum2(100)
dim ctnoOut
redim ctnoOut(100)
dim ct
redim ct(100)
dim f1, f2
Dim re1, re2
dim sum1, sum2

If Not rs.EOF Then
for c = 0 to ubound(counter)
response.write "<tr><td>"
while Not rs.EOF
dim formtext, c1
formtext=(rs.fi elds.item(ctr(c )).value)

formtext is always 2 but I expect it to be 2, then 4, then 6 etc.. How
do I pass the counter from the for loop to while?

Jul 18 '06 #1
1 1681
pa***********@g mail.com wrote:
Hi,

I'm trying to pass a parameter from a for loop to the nested while
loop but only the first counter is passed. Here is the code:

If Not rs.EOF Then
for c = 0 to ubound(counter)
response.write "<tr><td>"
while Not rs.EOF
dim formtext, c1
formtext=(rs.fi elds.item(ctr(c )).value)

formtext is always 2 but I expect it to be 2, then 4, then 6 etc.. How
do I pass the counter from the for loop to while?
First of all, it's not your problem, but don't declare (dim) formtext and c1
inside the loop. This is a bad practice. Variables should never be declared
inside a loop.
Also, use "Do While ... Loop" instead of the deprecated "While ... Wend"

"Pass" is not the correct terminology here. You "pass" arguments to methods.
This is simply a situation where an in-scope variable is used by a piece of
code. As to why the value assigned to formtext never changes, it's hard to
say without being able to debug your code. Your first step should be to
verify that c is incrementing the way you expect it to:

for c = 0 to ubound(counter)
Response.Write "c contains """ & c & """; "
Response.Write "ctr(c) contains """ & ctr(c) & """<BR>"
next

Once you have verified this, then work on the inner loop which you seem to
have snipped before we got to the interesting part.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '06 #2

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

Similar topics

21
1356
by: cjl | last post by:
Hey all: I have the following (ugly) code: function preload() { if (cr_series.length >1) preloadCR(); if (ct_series.length >1) preloadCT(); if (mr_series.length >1) preloadMR(); if (us_series.length >1) preloadUS();
8
5460
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I...
6
4974
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a...
7
9553
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a subroutine Let's say theres a sub that creates buttons and I want it to receive as a parameter the address of the sub that handles the OnClick event...
7
9693
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason for this being to stop the user thinking the application has frozen when in fact it is just waiting for a long SP to complete. Another reason for...
15
2565
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the...
1
6053
by: al2004 | last post by:
Write a program that reads information about youth soccer teams from a file, calculates the average score for each team and prints the averages in a neatly formatted table along with the team name. Please follow the specifications for assignment 3 as described below otherwise points will be taken off. Input from a file Please create an input...
10
2638
by: Lloyd Harold | last post by:
I'm very new to PHP and attempting to put together a simple script for retrieving MySQL data of personal records. The MySQL table I'm using consists of: 0: id 1: name 2: location (an integer relating to a separate table of locations). 3: details
2
10014
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name is used to access and read the value stored in it C.A variable is allocated or deallocated in memory during runtime D.A variable can be initialized...
0
7800
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8153
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6558
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5365
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3806
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3830
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1405
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1141
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.