When I running a loop: For Each File As System.io.FileI nfo In FileInfo
Is there a way to tell which file number (index) I'm currently on?
Actually I'd like the ability to skip to a particular index--either
forward or back. It'd be nice to be able to set the index back or
forward with a command button perhaps and the loop just move to that
position and continue forward from there.
I'm specifically interested in doing this in the for each loop. 13 2045
"cj" <cj@nospam.nosp am> schrieb: When I running a loop: For Each File As System.io.FileI nfo In FileInfo Is there a way to tell which file number (index) I'm currently on? Actually I'd like the ability to skip to a particular index--either forward or back. It'd be nice to be able to set the index back or forward with a command button perhaps and the loop just move to that position and continue forward from there.
I'm specifically interested in doing this in the for each loop.
I am curious why you are not using a 'For...To' loop.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Curiosity is a good thing. Right? I think so. Initially there was no
need for the functionality I'm requesting now and For Each is IMHO
specifically made for looping through collections/arrays so I used it.
So, why don't I change to "For To" etc now? Well, I will if I have to.
I am just curious if I could do this in For Each.
Hope someone knows.
Herfried K. Wagner [MVP] wrote: "cj" <cj@nospam.nosp am> schrieb: When I running a loop: For Each File As System.io.FileI nfo In FileInfo Is there a way to tell which file number (index) I'm currently on? Actually I'd like the ability to skip to a particular index--either forward or back. It'd be nice to be able to set the index back or forward with a command button perhaps and the loop just move to that position and continue forward from there.
I'm specifically interested in doing this in the for each loop.
I am curious why you are not using a 'For...To' loop.
"cj" <cj@nospam.nosp am> schrieb: Curiosity is a good thing. Right? I think so. Initially there was no need for the functionality I'm requesting now and For Each is IMHO specifically made for looping through collections/arrays so I used it.
I would say it has been introduced to simplify looping through a collection
or array when index-based access is not important. Obviously the latter is
important in the case you described...
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Cj,
A for each loop will only work forwards. You will need to use a for
next loop.
Ken
-------------------
"cj" wrote: When I running a loop: For Each File As System.io.FileI nfo In FileInfo Is there a way to tell which file number (index) I'm currently on? Actually I'd like the ability to skip to a particular index--either forward or back. It'd be nice to be able to set the index back or forward with a command button perhaps and the loop just move to that position and continue forward from there.
I'm specifically interested in doing this in the for each loop.
Hi cj,
Thanks for posting!
As Ken and Herfried mentioned, the "For Each" statement is not like the
"For" loop statement. Since "For Each" statement is only working forward,
there is no need to supply the functionalilty of the index. In this
scenario, I suggest you use the "For" loop statement instead of. I
appreciate your understanding.
Regards,
Yuan Ren [MSFT]
Microsoft Online Support
Um, "IndexOf" function perhaps? Arrays have this as do all the collections
AFAIK.
Though I would agree with what the others recommed as IndexOf would probably
slow down your loop and is sorta dumb to use if you can just change your
look to For x.. To.
"cj" <cj@nospam.nosp am> wrote in message
news:Oz******** ********@TK2MSF TNGP12.phx.gbl. .. Curiosity is a good thing. Right? I think so. Initially there was no need for the functionality I'm requesting now and For Each is IMHO specifically made for looping through collections/arrays so I used it.
So, why don't I change to "For To" etc now? Well, I will if I have to. I am just curious if I could do this in For Each.
Hope someone knows.
Herfried K. Wagner [MVP] wrote: "cj" <cj@nospam.nosp am> schrieb: When I running a loop: For Each File As System.io.FileI nfo In FileInfo Is there a way to tell which file number (index) I'm currently on? Actually I'd like the ability to skip to a particular index--either forward or back. It'd be nice to be able to set the index back or forward with a command button perhaps and the loop just move to that position and continue forward from there.
I'm specifically interested in doing this in the for each loop.
I am curious why you are not using a 'For...To' loop.
The Proper way to code this would be to use a a Do Loop and control the
increment manually.
Do Until whatever_condit ion
'do whatever work on
'fileInfo(i)
If whatever Then
i += 1
Else whatever2 then
i -= 3
...
End If
Loop
"Ken Tucker [MVP]" <Ke**********@d iscussions.micr osoft.com> wrote in message
news:82******** *************** ***********@mic rosoft.com... Cj,
A for each loop will only work forwards. You will need to use a for next loop.
Ken ------------------- "cj" wrote:
When I running a loop: For Each File As System.io.FileI nfo In FileInfo Is there a way to tell which file number (index) I'm currently on? Actually I'd like the ability to skip to a particular index--either forward or back. It'd be nice to be able to set the index back or forward with a command button perhaps and the loop just move to that position and continue forward from there.
I'm specifically interested in doing this in the for each loop.
cj When I running a loop: For Each File As System.io.FileI nfo In FileInfo Is there a way to tell which file number (index) I'm currently on?
Yes there is, however very inefficient to use, and because of the code bad
to maintain, so probably only used by bad developpers who want to obfuscate
there programs direct for everybody. http://msdn2.microsoft.com/system.co...numerator.aspx
The For Next Index gives all the information direct.
I hope this helps,
Cor
> The Proper way to code this would be to use a a Do Loop and control the increment manually.
Do Until whatever_condit ion
'do whatever work on 'fileInfo(i)
If whatever Then i += 1 Else whatever2 then i -= 3 ... End If Loop
Brrrrrrrrrrrrrr rr, proper for who, an assembler programmer, who learned less
or nothing from possibilities from higher languages.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jean-Christophe Michel |
last post by:
Hi,
I have a stylesheet with an accumulator like this
<xsl:param name="new-x">
<xsl:for-each select="anode">
<mynode>
<xsl:attribute name="attr">
<xsl:value select="anode/atag" />
</xsl:attribute>
|
by: matatu |
last post by:
Hi to everybody,
It's possible to exit from a cycle for-each?
I have this code:
1: <xsl:for-each select="field">
2: <xsl:variable name="tagfield" select="@tag"/>
3: <xsl:variable name="pos" select="position()"/>
4: <xsl:for-each select="/root/ass/istance">
|
by: deko |
last post by:
Problem: why doesn't this With block work? is it possible to have a For
Each loop within a With block?
With objWord
.Documents.Add Template:=strTemplate, NewTemplate:=False,
DocumentType:=0
For Each varBookmark In Array("ReturnAddress",
"NameAddressBlock", "Salutation", "FullName")
If DLookup(varBookmark, "tblTemplate", "template_ID = " &
strTid) = -1 Then
|
by: Floris van Haaster |
last post by:
Hi All!
I have a question, i have a web application and I store some member
information in a variable i declared in a module like:
Public some_info_variable as string
in module1.vb
But when another user comes to my website he is getting the same values from
the variable!!!
|
by: tshad |
last post by:
Is there a way to run a script or function on entry of each page without
having to put a call in each page?
Periodically, I find something I want to do each time a page is entered and
I have to go into each page and add a line or 2 in my asp.net code. That's
a lot of pages and I could easily miss one.
For example, I have a user object that I built that I just added a field -
LastPageVisited. This was necessary because, apparently,...
| |
by: Michael D. Ober |
last post by:
In VB 6, the loop iterator v in the following code must be a variant.
dim v as variant
dim c as new collection
for each v in collection
...
next v
What is the general translation in VB 7.1 and VB 8 Beta 1? Also, is there
an easy way to force "v" to be an early bound variable. In VB 6 this can be
|
by: Neal |
last post by:
Hi All,
I used an article on XSLT and XML and creating a TOC written on the MSDN
CodeCorner.
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dncodecorn/html/corner042699.htm
However, it did'nt quite answer all my questions.
How would one create a 3 level TOC when each item level / node was
differently named (They used Template match and for-each, but the template
match worked as on a 3 level structure they usedf the same named xml...
|
by: xmlhelp |
last post by:
stuff.XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="uid"/>
<xsl:template match="/">
parameter UID=<xsl:value-of select="$uid"/>
<table border="1">
<tr>
<xsl:for-each select="row/value=20]">
|
by: The Frog |
last post by:
Hello everyone,
I am working on an application that can build database objects in MS
Access from text files. I suppose you could call it a backup and
restore type routine.
Accessing the fields, tables, relationships, and indexes is no issue
for me via DAO code. The issue I have is that I am not sure which
properties are actually necessary / available to set from code for each
possible type of field. I have looked fo´r a reference on...
|
by: ADezii |
last post by:
If you want to visit each item in an Array, you have two alternatives:
Use a For Each..Next loop, using a Variant to retrieve each value in turn.
Use a For...Next loop, looping from the Lower Bound to the Upper Bound of the Array.
For Each...Next seems simpler because you need not worry about retrieving the Lower and Upper Bounds- the loop takes care of that for you.
For Each varValue In alngValues
j = varValue
Next varValue...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |