|
-
Sep 19th, 2006, 09:13 PM
#1
Thread Starter
Junior Member
[Resolved]
NEW QUESTION:
i want to have 1 text file, and that text file will have like:
amy
bob
joe
suzie
and i want each line to be put into a variable. like we did before, but not JUST for the first line.
but... because i won't know in advance how many lines there will be (long story)... i need VB to continue puttin lines into variables until it gets to the end. OR it just counts how many lines their are or something.
OLD question:
i need to read the first line of a text file, and then IF that line is different from the first line of another text file, then a message box will appear.
and like i used the comparing code from here:
My File Compare Code
and that worked. so i guess i just need to know how to ONLY read the first line.
Last edited by JustinMs66; Sep 19th, 2006 at 11:56 PM.
-
Sep 19th, 2006, 09:27 PM
#2
Member
Re: Comparing ONLY the First Line of 2 Text Files
Yep, try this ...
VB Code:
Dim File1Data, File2Data As String
Open "c:\updates_vbc.txt" For Input As 1
Open "c:\updates_vbc2.txt" For Input As 2
Line Input #1, File1Data
Line Input #2, File2Data
If File1Data <> File2Data Then MsgBox "Dese ain't da same, bub!"
Close 2, 1
-
Sep 19th, 2006, 10:07 PM
#3
Thread Starter
Junior Member
Re: Comparing ONLY the First Line of 2 Text Files
awesome!!! that is 100% exactly what i needed.
now another question...
what is the VB code for launching a external EXE and then exiting the current application
-
Sep 19th, 2006, 10:33 PM
#4
Addicted Member
Re: Launching An External EXE File
Try using the SHELL operation
Examples:
For a normal focus use:
VB Code:
shell "C:\Windows\Notepad.exe",vbNormalFocus
For a maximised focus use:
VB Code:
shell "C:\Windows\Notepad.exe",vbMaximizedFocus
You can also use a program to open a file like this:
VB Code:
shell "C:\Windows\Notepad.exe c:\updates_vbc2.txt",vbMaximizedFocus
After you shell it just type "End" after the shell line
Hope this helps
Dan "  "
Visual Basic Professional 6.0
-
Sep 19th, 2006, 11:06 PM
#5
Thread Starter
Junior Member
Re: Launching An External EXE File
New Question!
i want to have 1 text file, and that text file will have like:
amy
bob
joe
suzie
and i want each line to be put into a variable. like we did before, but not JUST for the first line.
but... because i won't know in advance how many lines there will be (long story)... i need VB to continue puttin lines into variables until it gets to the end. OR it just counts how many lines their are or something.
Last edited by JustinMs66; Sep 19th, 2006 at 11:13 PM.
-
Sep 20th, 2006, 04:13 AM
#6
Re: [Resolved]
VB Code:
Dim sLines() As String
Open [i]filename[/i] For Input As #1
sLines = Split(Input(LOF(1), #1), vbCrLf)
Close #1
the sLines array now contains all the lines of your txt file
-
Sep 20th, 2006, 08:06 AM
#7
Member
Re: [Resolved]
I've been VB programming since 1995. I swear I've never heard of the SPLIT function until I found this site just recently. For all these years I've developed my own parsing functions, only to have SPLIT show up in my life!
-
Sep 20th, 2006, 08:34 AM
#8
Re: [Resolved]
it was new for VB6 - here are some fast(er) alternatives @ VBspeed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|