Results 1 to 8 of 8

Thread: [Resolved]

  1. #1

    Thread Starter
    Junior Member JustinMs66's Avatar
    Join Date
    Jun 2006
    Location
    CA, USA, EARTH
    Posts
    21

    Arrow [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.

  2. #2
    Member
    Join Date
    Sep 2006
    Posts
    37

    Re: Comparing ONLY the First Line of 2 Text Files

    Yep, try this ...

    VB Code:
    1. Dim File1Data, File2Data As String
    2. Open "c:\updates_vbc.txt" For Input As 1
    3. Open "c:\updates_vbc2.txt" For Input As 2
    4.     Line Input #1, File1Data
    5.     Line Input #2, File2Data
    6.     If File1Data <> File2Data Then MsgBox "Dese ain't da same, bub!"
    7. Close 2, 1

  3. #3

    Thread Starter
    Junior Member JustinMs66's Avatar
    Join Date
    Jun 2006
    Location
    CA, USA, EARTH
    Posts
    21

    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

  4. #4
    Addicted Member DanCool999's Avatar
    Join Date
    Jul 2006
    Posts
    141

    Lightbulb Re: Launching An External EXE File

    Try using the SHELL operation

    Examples:
    For a normal focus use:
    VB Code:
    1. shell "C:\Windows\Notepad.exe",vbNormalFocus
    For a maximised focus use:
    VB Code:
    1. shell "C:\Windows\Notepad.exe",vbMaximizedFocus
    You can also use a program to open a file like this:
    VB Code:
    1. 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

  5. #5

    Thread Starter
    Junior Member JustinMs66's Avatar
    Join Date
    Jun 2006
    Location
    CA, USA, EARTH
    Posts
    21

    Arrow 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.

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [Resolved]

    VB Code:
    1. Dim sLines() As String
    2.  
    3. Open [i]filename[/i] For Input As #1
    4.     sLines = Split(Input(LOF(1), #1), vbCrLf)
    5. Close #1
    the sLines array now contains all the lines of your txt file

  7. #7
    Member
    Join Date
    Sep 2006
    Posts
    37

    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!

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    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
  •  



Click Here to Expand Forum to Full Width