CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Location
    United Kingdom
    Posts
    15

    Varible not defined ???

    Could someone explain to me what's wrong with this piece of code which should create a text file called user.txt and put whatever has been typed in a text box into the file. But when the program is run I get the compile error "Varible not defined", that is wrong with the code?

    Dim dateiname as string, dateinr as Integer
    DirPath = (App.Path & "\logon\")
    dateiname = DirPath & "user.txt"
    dateinr = FreeFile
    Open dateiname for Output as dateinr
    print #dateinr, txtUser.Text
    Close dateinr



    Jonathon.


  2. #2
    Join Date
    Jan 2000
    Location
    Saskatchewan, Canada
    Posts
    595

    Re: Varible not defined ???

    Maybe

    Dim DirPath as string

    David Paulson


  3. #3
    Join Date
    Aug 2001
    Location
    United Kingdom
    Posts
    15

    Re: Varible not defined ???

    Thanks David

    Jonathon.


  4. #4
    Join Date
    Sep 2001
    Posts
    16

    Re: Varible not defined ???

    Hi,
    U can use the FileSystemObject to return a text stream object that can be read from or written to:

    Dim fs,mf
    set fs=CreateObject("Scripting.FileSystemObject")
    set mf=fs.CreateTextFile("c:\textfile.txt,True)
    mf.writeline("This is a sample text.")
    mf.close

    try the above code for creating a text file with the text.
    Have a nice time
    sunil.



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