Re: Need some help please ! !
- From: argusy <argusy@xxxxxxxxxxxxxxx>
- Date: Sat, 20 May 2006 11:18:25 +0930
For a start never, EVER use "<>" to define a count up or count down,
because if your code happened to start outside your boundary, then you've got an infinite loop - ergo, program 'hangs'
It is far safer to use "less than" ('<') in your particular code.
Your code should be
If counter < NumberOfLines then ...
but that won't do what you want anyway.
in your code, it only happens once, then the code drops down to the loop, looking for the next input. (Which is why your output file matches your input file)
as Richard showed, you need to put in a secondary loop
what happens if you have "Test100" or "Bitmap100"??
getting a left string or mid string with fixed numbering could crash your following code
personally, I would use Right(A$,2), or do a string search for the second comma, and extract the following number (no matter how many digits in it)
(Bit of research here into the use of mid$ and instr$)
Umm, sorry, there's no point to formatting 'counter' as you have.
You've dimensioned 'counter' as a variant, then immediately redefine it as an integer, so there's no point in having ' Counter = Format$(Counter, "00")'
You might as well remove it from your code
See my comments tacked onto your code below
Argusy
Henkie wrote:
Hello all, I have the following that I can not getting work, for example' now if counter was a string, it would be "01", but it's an integer
my input file is as below
Test01,Bitmap01,01
Test02,Bitmap02,02
Test04,Bitmap04,04
Test05,Bitmap05,05
Test03,Bitmap03,03
The file I want created out of this is as below
Test01,Bitmap01,01
Test02,Bitmap02,02
Test02,Bitmap02,02
Test04,Bitmap04,04
Test04,Bitmap04,04
Test04,Bitmap04,04
Test04,Bitmap04,04
Test05,Bitmap05,05
Test05,Bitmap05,05
Test05,Bitmap05,05
Test05,Bitmap05,05
Test05,Bitmap05,05
Test05,Bitmap05,05
Test03,Bitmap03,03
Test03,Bitmap03,03
Test03,Bitmap03,03
I want for each line in the output as many lines as
are giving in the input file in charcter 17 till 18
I think that is clear how I want te output.
the code I using is here below but that is not
working, i hope that someone can help me
on the good way. I am rather new in VB
Dim NumberOfLines ' it's a variant
Dim Counter ' it's a variant
Counter =1 ' OK, now it's an integer
' Do While Not EOF(1)
'
Counter = Format$(Counter, "00") 'hey, what!! doesn't do anything
Line Input #1, A$
NumberOfLines = Mid(A$, 17, 2) ' OK, now it's an integer' that works, but there's a safer method using mid$ and instr$
If Counter <> NumberOfLines Then ' could match at least once with data
Print #2, Left(A$, 18) ' so will probably print at least once
Counter = Counter + 1 ' yep, counter has incremented - so what?
End If ' removed the "'" in front of this
Teller = 1 ' ???
'
Loop ' now go and get another line
Now with this code my output file is the same as my input file :-(
Hope that someone can give me some help.
Greetings
Henkie
.
- Follow-Ups:
- Re: Need some help please ! !
- From: argusy
- Re: Need some help please ! !
- References:
- Need some help please ! !
- From: Henkie
- Need some help please ! !
- Prev by Date: Re: Need some help please ! !
- Next by Date: Re: Need some help please ! !
- Previous by thread: Re: Need some help please ! !
- Next by thread: Re: Need some help please ! !
- Index(es):
Relevant Pages
|