Editing text file

June 25, 2010 at 01:58:08
Specs: Windows XP, P4, 512mb
I have a program like the picture below, I desgning it with VB6.

-------------------------------------------
| ............................................... | Find File
-------------------------------------------
------------------------------------------
| .............................................. | Place File
------------------------------------------

----------- ------------- -----------
| Clear | | Process | | Closed |
----------- ------------- -----------

I want to edit a text file with leading zero, the file content is :

:20:201006170828153
:25:186350587
:28:153
:60F:C100602IDR879511164,
:61:1006020602DR313600,NTRF//
:20:201006170828154
:25:186350587
:28:154
:60F:C100603IDR462231690,
:61:1006030603CR918000000,NTRF//
:20:201006170828155
:25:186350587
:28:155
:60F:C100604IDR703646190,
:61:1006040604DR440000000,NTRF//
:86:TARIK TRF (RTGS) | N WILLY MANOBY | HLP/121339 |0020005710DG10
:61:1006040604DR15000,NTRF//
:86:TARIK TRF (RTGS) | N WILLY MANOBY | HLP/121339 |0020005710DG10
:61:1006040604DR88500000,NTRF//

I want to insert every
:25:
with two zero, so it will look like
:25:00

Is there any possibility to make such a program with any languange? for example VB or C.

I am too confused to do this cause I am a new in programming.

Could anyone help me?

Thanks.
Andi


See More: Editing text file

Report •


#1
June 25, 2010 at 07:24:01
Wasn't this answered here?
...edit-and-replace-text-with-batch/21767.html

Insomniac at large


Report •

#2
June 25, 2010 at 08:54:05
here's some slop in vb to work with:
open "file.txt" for input as #1
open "new.txt" for output as #2
do while not eof(1)
line input #1,k
10
p=instr(k,":25:")
if p>0 then
k=left(k,p+3)+"00"+mid(k,p+4)
goto 10
print #2,k
loop
'-------- end
or if you just want the beginnings of lines:
do while not eof(1)
line input #1,k
if left(k,4)=":25:" then k=left(k,4)+"00"+mid(k,5)
print #2,k
loop

Report •

#3
June 27, 2010 at 18:35:04
@Orangeboy
Try to make program with another language

@nbrane
Ok I'll try the script

Thanks All
Andi


Report •

Related Solutions

#4
July 14, 2010 at 21:42:41
Hi All,

My problem solved with this code with textbox and command :

Private Sub cmdProses_Click()
Dim txt
txt = TextBox.Text
If InStr(1, TextBox.Text, ":25:") > 0 Then
TextBox.Text = Replace(txt, ":25:", ":25:00")
End If
End Sub

But I have a knew problem, If my text contain this :

:25:0186350587
:25:186350587
:25:86350587
:25:6350587
:25:350587
:25:50587
:25:587
:25:87
:25:7

I want it to insert zero number after :25: , but the number after :25: is always has to be 10 digit. So it would be :

:25:0186350587
:25:0186350587
:25:0086350587
:25:0006350587
:25:0000350587
:25:0000050587
:25:0000000587
:25:0000000087
:25:0000000007

with my code in vb6 it only insert two digit of zero number, so it would be :

:25:000186350587 (more than 10 digit)
:25:00186350587 (more than 10 digit)
:25:0086350587 (10 digit)
:25:006350587 (less than 10 digit)
:25:00350587 (less than 10 digit)
:25:0050587 (less than 10 digit)
:25:00587 (less than 10 digit)
:25:0087 (less than 10 digit)
:25:007 (less than 10 digit)

Would you like to help me with the new code please

Thank you
Andi.


Report •

#5
July 15, 2010 at 11:55:07
i'll borrow the technique from batch:
k=textbox.txt
p=InStr(k, ":25:")
if p > 0 Then
k=left(k,p+3)&right("0000000000"&mid(k,p+4),10)
TextBox.Text = k
End If
'---------- (not tested.)

Report •


Ask Question