Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Easy answers for anyone

"m5u4r3p2h1y" wrote:
in message ...
was hoping if anyone code tell me why the following code
only loops once.

[....]
Dim i, count As Integer

[....]
For i = 0 To i = 9


The For statement should be:

For i = 0 to 9

As you wrote, it is parsed as:

For i = 0 to (i = 9)

"i = 9" returns True (-1) or False (0). Since i=0 initially, "i = 9" is
False (0). So your For statement is effectively:

For i = 0 to 0

which will indeed loop only once.

By the way, you Dim statement should probably be at least:

Dim i As Integer, count As Integer

As you wrote it, i is Variant. I suspect that was not your intent.

Also, there is little point in using Integer type, unless you have very huge
arrays. You should use Long to be flexible. There is no performance cost
in modern computers.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum of yes answers Linda L Excel Worksheet Functions 2 December 23rd 09 06:04 PM
multiple answers AndyS Excel Worksheet Functions 3 October 16th 06 09:14 AM
Please help me with answers Michael Wiredu Excel Discussion (Misc queries) 2 August 24th 06 05:39 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
Does anyone know the answers to DK Links and Linking in Excel 0 May 23rd 05 11:14 PM


All times are GMT +1. The time now is 08:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"