Re: Need some help please ! !

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
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
' now if counter was a string, it would be "01", but it's an integer

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




.



Relevant Pages

  • Re: run code on multiple xls files
    ... Refactor the present code such that it takes two arguments, ... the names of the input file and the output file ... Write a loop that calls the '1-file code' and calls it ...
    (comp.soft-sys.matlab)
  • Re: bit-plane operation, for loop
    ... able to read the bit position inside the for loop ... charRepresentation = b, row, col), k) ...
    (comp.soft-sys.matlab)
  • Re: run code on multiple xls files
    ...    the names of the input file and the output file ... Write a loop that calls the '1-file code' and calls it ...    with each of the input/output pairs of file names. ...
    (comp.soft-sys.matlab)
  • Re: Help is needed to compile C program using Visual Studie 2005
    ... the pdb file that was used when this precompiled header was created, ... an output file whose name has the following format: ... The length of input file paths and name must be less than 256; ... while(i < DefinedVariableArrayIndex) { ...
    (microsoft.public.vc.language)
  • Re: Need advice on File I/O
    ... open the input file and open an output file, ... you would still have the input file unchanged. ... On all currently supported operating systems, ...
    (comp.soft-sys.matlab)