Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check of valute change in text file 3

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
428
IT
I ready a text file with a line by line.

I can have in text file:

1111
1111
1111
1111
1111
2222
2222
2222
3333
3333
5555
5555
5555
6666
8888
8888
9999

I get the value similar

Myvar=Left 4 of line

Now i need to check.
When 1111 <> 2222

Then stop

 
And that's all you need to do is it? There're no additional requirements?
 
Could be, could be. But very much depends on what sal21's actual requirements are, as I bet they are not just as has been stated so far.
 
Sample....
First occorrente = 11111, loop line by line, 11111<>22222, then, call my code, actually 22222<>33333, then call my code, ecc...
 
So, what have you tried so far? Show your code, even if it does not work correctly...

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Bro.
No code, not have idea to do.
Sorry
 
So, what you are saying is: I am a ‘programmer’ and I have this task to do, but I don’t know how to read a text file, I don’t know how to step/loop thru it, and I don’t even want to Google it or do anything to accomplish my task. But I want somebody to give me a working, ready to use code so I can just plug it into my application and move to another issue that somebody else will have to help me with.
[ponder]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Maybe Sal wants to compare the current line to the previous line.

@Andrzejek: When you sign up for Tek-Tips you're given the opportunity to identify yourself as 'programmer', 'technical user', 'MIS', 'systems engineer', etc. I don't think that 'leech' is an option
 
>First occorrente = 11111, loop line by line, 11111<>22222, then, call my code, actually 22222<>33333, then call my code, ecc...

@sal21
So pretty much each time the code changes. Which is what I suspected[sup]*[/sup], and wrote a quick solution for (and SaltyTheFrog's suggestion, if you didn't rely on us to do your programming for you, would have been a clue to the approach), but I didn't bother posting is straightaway because you appear to reverted to an old behaviour of yours which is to not bother responding once you've got what you need or lost interest or become 'too busy', as the following threads just from the last month indicate

thread222-1829468
thread222-1829532
thread222-1829598

and this very thread (unless it was you who starred mintjulep's post, which I doubt). Strangely enough, a fair few of us in these forums actually like trying to help people - but there are limits to our patience if we feel we are being taken advantage of, as a couple of the posts in this thread are hinting at.

Anyway, here's the code. It is not quite the simplest version, for various reasons I am not going into.

Code:
Public Sub Sal21_101()
    Dim newstr As String
    Dim oldStr As String
    
    With New FileSystemObject
        With .OpenTextFile("D:\Downloads\DeleteMe\simple.txt", ForReading) [COLOR=green]' use your own filename here[/color]
            oldStr = .ReadLine
            Do
                Do
                    newstr = .ReadLine
                Loop Until newstr <> oldStr
                Debug.Print oldStr
                [COLOR=green]'your code goes here>[/color]
                oldStr = newstr
            Loop Until .AtEndOfStream
        End With
    End With
End Sub

[small][sup]*[/sup] I also suspect that your real text file is NOT just a list of code numbers[/SMALL]
 
hI bro,tested your code and it work great!
Only one...

i need to start from the second line of txt.
The first line have a not important string
How to?

In effect i have in origina txt:

TITLE
1111
1111
1111
1111
1111
2222
2222
2222
3333
3333
5555
5555
5555
6666
8888
8888
9999
...
 
This approach must be taken from this place

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
And so, with more of a whimper than a bang, the Visual Basic Forum dies out.....
I strongly suspect that Sal21 and Luca2009 are the only people actively posting "questions:" to this forum.

Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
>How to
Just needs 1 extra line in my code, which was designed to allow such a modification (hence my comment that it "It is not quite the simplest version")

See if you can figure where that one lione needs to go and what it might be. Hint - you just want to ignore the first line ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top