LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Changing Do Loop to For loop

Folks,

I need to change the Do loop below to a For loop reason being that Do loop
as structured below grabs the 1st instance of the string whereas I want the
last instance of the string and I think For loop will let me do that but I am
getting an error.

Do Loop (ORIGINAL):

Do While Not objTechAttrFile.AtEndOfStream
strLine = objTechAttrFile.Readline

If InStr(strLine, "tech.tech") < 0 Then
Buf() = qc_Split(strLine)
TechFileVersion = Buf(3) 'get version of tech file to open
Exit Do
End If

Loop

Issue above is that I can't think i.e. can't figure out how to change to For
loop without getting an error. Here's my for loop to get the last instance
of string tech.tech in the file but I get an error.

For Loop (DOESN'T WORK):

For tech_attribute_file_lines = 1 To objTechAttrFile.AtEndOfStream
strLine = objTechAttrFile.Readline

If InStr(strLine, "tech.tech") < 0 Then
Buf() = qc_Split(strLine)
TechFileVersion = Buf(3) 'get version of tech file to open
End If

Next tech_attribute_file_lines

What's wrong with the FOR loop? Help is appreciated
 
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
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Changing a variable which is to be specified through a loop Wesslan Excel Programming 2 March 12th 08 04:16 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
Oject value changing in a loop Neal Zimm Excel Programming 2 March 24th 06 08:05 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM


All times are GMT +1. The time now is 02:40 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"