473,320 Members | 1,817 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,320 software developers and data experts.

Why my For Each block does not work?

!NoItAll
297 100+
This one is really perplexing me...
First some working stats...
  • Visual Studio 2015
  • Visual Basic .NET
  • Framework 4.6.1
  • Windows 10 x64
I have a small codeblock
Expand|Select|Wrap|Line Numbers
  1. For Each src As CommonStructures.Source_Type In SourcesConfig.Sources.Source
  2.     ManageImageAndLatestFolders(src, ActionEnum.Add)
  3. Next
  4.  
Intellesense indicates there are 8 elements of the SourcesConfig.Sources.Source object and that the types are derived from the same class (not duplicates, the same class). With the above block the ManageImageAndLatestFolders sub is never called!

However...

The same block of code works just fine

Expand|Select|Wrap|Line Numbers
  1. For I as Integer = 0 to (SourcesConfig.Sources.Source - 1)
  2.     ManageImageAndLatestFolders(SourcesConfig.SOurces.Source(I), ActionEnum.Add)
  3. Next I
  4.  
Although the form is different, the two routines above are identical in function. The For Each block, however, does not iterate through the src items (of which there are clearly 8).
I have tried to clean the application(Build -> Clean [Project]).
Any thoughts from anyone? What might I be missing?

I use For Each in lots of places in my code - and because of this anomaly I am afraid I'm doing something wrong that might be affecting much of my work!
Jan 5 '17 #1
2 1192
!NoItAll
297 100+
Well - more information...
It actually is executing as it should, but the debugger simply does not step into it the way I expect it to. If I put a breakpoint inside of the ManageImageAndLatestFolders sub, it runs 8 times - however when stepping through the code it never steps onto the ManageImageAndLatestFolders sub!
This seems like a Visual Studio bug to me. I've checked all of the Debugging options and find nothing obvious...
Jan 5 '17 #2
Frinavale
9,735 Expert Mod 8TB
What is SourcesConfig.Sources.Source??

In the first code block you are using it like an array or collection of some sort:
Expand|Select|Wrap|Line Numbers
  1. For Each src As CommonStructures.Source_Type In SourcesConfig.Sources.Source
In the second code block you are using it like an integer and subtracting one from it:

Expand|Select|Wrap|Line Numbers
  1. For I as Integer = 0 to (SourcesConfig.Sources.Source - 1)
If it is an integer, then your foreach obviously won't work because it's not a collection...

Maybe your foreach should be as follows??
Expand|Select|Wrap|Line Numbers
  1. For Each src As CommonStructures.Source_Type In SourcesConfig.Sources
But then again, you are treating it like an array/collection here:

Expand|Select|Wrap|Line Numbers
  1. ManageImageAndLatestFolders(SourcesConfig.SOurces.Source(I), ActionEnum.Add)
It would help to know what things are. Also if you are using structures or classes?

-Frinny
Jan 11 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Peter | last post by:
L.S. I am developing a PHP-login script (on Lycos Tripod) that uses Session to pass on variables. Below is the entire (stripped) structure that I use. It opens a page where you can Set and Read...
3
by: cv | last post by:
Hello All, I have used MultipartRequest like the following to upload images. MultipartRequest multi = new MultipartRequest(request, "../webapps/coreprogram/dealerlogos", 1024 * 1024); It...
4
by: Field | last post by:
Hi, the following snippet shows once executed this output: 2 2 I'd have rather expected this output: 2 10
4
by: Das | last post by:
Hi, I have made an application in ASP.net with C#. The application works fine with localhost. I have uploaded the site. I'm using web user controls in the form. but some of the button do not work...
7
by: Tom | last post by:
Hi Is this a conditional ? what is the structure of the statement? ch Tom
10
by: Antoine | last post by:
I can't work out what is causing this problem. Can anyone suggest what the typical causes beyond the obvious might be? Could you get it with datasets? Maybe I should run in debug mode and test...
5
by: Jason | last post by:
I've got a small form (400 X 310) and I want it to start up in the lower right corner of the screen. Is there a way I can easily do this? Thanks
1
by: =?Utf-8?B?Uk1C?= | last post by:
I am using the Configuration Application Block, and I want to keep my config files in a folder off of the app root called config. I have modified the app.config to point to the folder with a...
1
by: Newbie in ChiTown | last post by:
Here's my code: I am using MS Access and I am trying to update a table (InvoiceDetails) with data input by the user on a form. However, it does not update nor does it give me an error message. ...
11
by: Jim | last post by:
Hi, I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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
0
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...
0
isladogs
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...

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.