CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 1999
    Posts
    16

    Newbie needs help for last time....and i'll leave you alone

    Hi,
    My previous post was answered but I don't think I made it all that clear. Thanks for whoever answered it by the way. I need a macro to go with my Java program. What it needs to do is:
    Open a file("file.doc");
    Read the first line of ("file.doc");
    The information read is the name of the second file. Say for example the first line read is "test.doc", the program needs to open up a second file named "test.doc". I need to know after I read the first line, how do I translate this into a file. I've tried the "&" method with strings but can't get it to work. Thanks so much ahead of time. Mr. Bean


  2. #2
    Guest

    Re: Newbie needs help for last time....and i'll leave you alone

    Sorry I did not fully understand your last request. Hopefuly this will help you out. It assumes that the files you are opening are in it's directory and that the last file has the word 'stop' in it.
    EG.
    File.txt looks like this:
    1.txt
    1.txt Looks like this:
    2.txt
    2.txt Looks like this:
    3.txt
    3.txt Looks like this:
    stop

    This will open 1.txt, 2.txt, and 3.txt assuming the first line has the file name to be opened or the stop and nothing else. The rest of the file can be whatever. Have fun. By the way my e-mail is [email protected] if you need further help or a zipped demonstration.


    private Sub Command1_Click()
    Dim GotFirstFile as Boolean
    GotFirstFile = false
    Dim INTPATH as string
    Dim Path(256) as string 'Max file layers is 256
    Dim i as Integer

    Open App.Path & "\File.txt" for input as #1
    Line input #1, INTPATH
    Shell "C:\Windows\Notepad.exe" & " " & App.Path & "\" & INTPATH
    Close #1


    Open App.Path & "\" & INTPATH for input as #1
    Line input #1, Path(1)
    Shell "C:\Windows\Notepad.exe" & " " & App.Path & "\" & Path(1)
    GotFirstFile = true

    Close #1


    for i = 1 to 256

    Dim INLINE as string

    Open App.Path & "\" & Path(i) for input as #1
    Line input #1, INLINE
    If INLINE = "stop" then
    GoTo NOFILE
    else
    'Assume the file has a path in it
    Shell "C:\Windows\Notepad.exe" & " " & App.Path & "\" & INLINE
    Path(i + 1) = INLINE
    Close #1
    End If

    next

    NOFILE:
    End
    End Sub





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

Featured