Results 1 to 9 of 9

Thread: Text file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    13

    Text file

    hi, Shouldn't this open a *.txt -file?
    (because it doesn't..)

    Private Sub Code_Click()

    Dim filnummer As Integer
    Dim filnavn As String

    'Unikt filnummer findes
    filnummer = FreeFile
    filnavn = "C:\Documents and Settings\whiteraven\Dokumenter\game\Code.txt"

    Open filnavn For Input As #filnummer
    Close #filnummer

    End Sub
    I'm so n00b @ diz

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Text file

    Originally posted by whiteraven
    hi, Shouldn't this open a *.txt -file?
    (because it doesn't..)

    Private Sub Code_Click()

    Dim filnummer As Integer
    Dim filnavn As String

    'Unikt filnummer findes
    filnummer = FreeFile
    filnavn = "C:\Documents and Settings\whiteraven\Dokumenter\game\Code.txt"

    Open filnavn For Input As #filnummer
    Close #filnummer

    End Sub
    You are opening it. For the app, that is. You can't see it. Then you're closing it.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Are you looking to shell the file so that you can visibly see it?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    13
    okay, I kinda thought so.. Isn't there a way to make it open the .txt -file so that it comes visible?
    I'm so n00b @ diz

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    13
    I just wan't to make it open the .txt -file so that I can see it. I don't know why, but I just thought that would be really cool.. hehe
    I'm so n00b @ diz

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. 'Make a new project. To the form add a CommonDialog control, a text box and a command button.
    2.  
    3. 'Code:
    4. Option Explicit
    5.  
    6. Private Sub Command1_Click()
    7.     Dim FileName As String
    8.     Dim F As Integer
    9.     CommonDialog1.ShowOpen
    10.     FileName = CommonDialog1.FileName
    11.     F = FreeFile
    12.     Open FileName For Input As #F
    13.     Text1.Text = Input$(LOF(F), F)
    14.     Close #F
    15. End Sub
    -= a peet post =-

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    13
    Thx! I'll try that, damn this forum rox!
    I'm so n00b @ diz

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by peet
    VB Code:
    1. 'Make a new project. To the form add a CommonDialog control, a text box and a command button.
    2.  
    3. 'Code:
    4. Option Explicit
    5.  
    6. Private Sub Command1_Click()
    7.     Dim FileName As String
    8.     Dim F As Integer
    9.     CommonDialog1.ShowOpen
    10.     FileName = CommonDialog1.FileName
    11.     F = FreeFile
    12.     Open FileName For Input As #F
    13.     Text1.Text = Input$(LOF(F), F)
    14.     Close #F
    15. End Sub
    And here's YOUR sign!

    (Woohoo!)


    Here's how you would shellexecute the .txt file to display it:

    VB Code:
    1. 'General Section
    2. Private Declare Function ShellExecute Lib "shell32.dll" Alias _
    3.         "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
    4.         As String, ByVal lpFile As String, ByVal lpParameters _
    5.         As String, ByVal lpDirectory As String, ByVal nShowCmd _
    6.         As Long) As Long
    7.  
    8.  
    9. 'in the form code
    10.   Call ShellExecute(Me.hwnd, "Open", "C:\file.txt", "", "c:\", 1)

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Denmark
    Posts
    13
    It works now!

    It look really cool, it was for a small game that I made in VB. The "Beta-tester's" should be able to view the code.. Hehe, it was an "3-in-a-row"-game.. Thx for all the help from U guys! C ya!
    I'm so n00b @ diz

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