VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 300,391 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,568 people online right now. Registration is fast and FREE... Join Now!




Duplicate lines

 

Duplicate lines

sathish_bhaskar

30 Jun, 2009 - 02:20 AM
Post #1

New D.I.C Head
*

Joined: 11 May, 2009
Posts: 4

Hi, i am saty.

I have a try.txt file which contains names like this,

saty
saty
michael
liz
maddy
saty
saty
liz
michael
michael
maddy
saty

can anybody tel me how to filter the names and write it in a separate file

my code looks lik this,

Set ws = CreateObject("Scripting.FileSystemObject")
Set w = ws.CreateTextFile("try1.txt", True) '

Open "try.txt" For Input As #33
Line Input #33, laymatch1
w.writeline (laymatch1)
Close #33


line1:

For k = 0 To noslines
Line Input #33, laymatch2
If Not (laymatch1 = laymatch2) Then
GoTo line3:
End If
Next k
line3:
w.writeline (laymatch2)
laymatch2 = laymatch1
goto line1:

w.close
close #33

i need the output lik this

saty
michael
liz
maddy


Thanks

User is offlineProfile CardPM
+Quote Post


firebolt

RE: Duplicate Lines

30 Jun, 2009 - 03:45 AM
Post #2

D.I.C Lover
Group Icon

Joined: 20 Feb, 2009
Posts: 5,463



Thanked: 75 times
Dream Kudos: 1675
My Contributions
Firstly, this is the wrong forum and secondly, please post all codes like so code.gif
User is offlineProfile CardPM
+Quote Post

vb5prgrmr

RE: Duplicate Lines

30 Jun, 2009 - 09:09 PM
Post #3

D.I.C Regular
***

Joined: 21 Mar, 2009
Posts: 459



Thanked: 30 times
My Contributions
It might be easier to use the input function to read the whole file in at once, the split the file into an array on vbNewLine. After that, perhaps a sorting routine if you want, then something like your output code.


Good Luck


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 09:47PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month