Monday, January 26, 2009

How to create text file in vb6.0?

Creating and Writing text in Text file or Notepad in Visual Basic 6.0 here the following procedure. In this example i have 1 text box in my form and 1 command button in my form. After clicking your command button basically it will create notepad and write text depending the text that you inputted in you text box. You can download this example below.

















You can download my example below.


Download File

19 comments:

  1. Its not working, check your code and upload proper code to site, please test before upload to site, dont let user to download codes

    ReplyDelete
  2. Create the file but does not write on it

    ReplyDelete
  3. Private Sub Command1_Click()
    Dim val As String

    'Creating text file==============================
    Open "C:\textFile.txt" For Output As #1
    Close #1
    '================================================

    'Writing text inside your text file============
    val = Text1.Text
    Open "C:\textFile.txt" For Output As #1


    Print #1, val

    '===============================================

    MsgBox "Check you text file in drive C", vbExclamation

    End Sub



    I'm sorry for inconvenience, this one work 100%.

    Thanks

    ReplyDelete
  4. how get text from note pad to lisbox

    ReplyDelete
  5. pls hlep me for writing code in VB using text file ... for eg in text file the content as a 234 34 22 b 23 45 45 c 834 44 43 soon...
    if i give a then i must get 234 34 22 and b means then 23 45 45 like this i need ... pls hepl me in creating

    ReplyDelete
  6. First thing to do open your vb6 and save it into a specific folder, then create a Textfile save it inside the folder that you've created and inside the textfile put this value as you given above.

    Try this one.

    Private Sub Command1_Click()
    Dim str As String
    Open App.Path & "\textfile.txt" For Input As #1

    While Not EOF(1)
    Line Input #1, str
    List1.AddItem str
    Wend
    Close #1
    End Sub

    ReplyDelete
  7. For writing in notepad, the code is fine, but my problem is that, after writing in notepad a break line append at the end of the file.
    For ex. if i write "Hello World" in notepad, and open the notepad, then the cursor blink at the first character, and when i click ctrl+end then the cursor blink in a new line rather the the last character ie. "d". I want the when i click ctrl+end the cursor must blink after d.

    Thanks in advance, please help me if you know.

    email me at : narendra@eoctagon.com

    ReplyDelete
  8. Hi..
    this is running successfully,

    thanks
    Nantha

    ReplyDelete
  9. For writing in notepad, the code is fine, but my problem is that, after writing in notepad a break line append at the end of the file.
    For ex. if i write "Hello World" in notepad, and open the notepad, then the cursor blink at the first character, and when i click ctrl+end then the cursor blink in a new line rather the the last character ie. "d". I want the when i click ctrl+end the cursor must blink after d.

    Thanks in advance, please help me if you know.

    mail to:touchwithkarthik@gmail.com

    ReplyDelete
  10. I need to create a text file and a data base of MicroSoft Access with extension .txt and .mdb resp. at runtime through codding . Is there anyone who can help me !!

    ReplyDelete
  11. i need to know the tags/codes to create commands like open,save,save as,find,print?

    ReplyDelete
  12. how to write to C file from textbox using vb6.0???

    ReplyDelete
  13. how do we create a text file

    ReplyDelete
  14. how to update a file

    ReplyDelete
  15. Hello everyone, I wanna to ask you about "How to add data form VB_Form into Text file.
    Please!help me, and send me with sample in the following Email: chheyleangpen@gmail.com

    ReplyDelete
  16. please help me
    use VB6
    create a text file called contacts using Notepad (programs> accessories > Notepad) with n=15
    records for storing their name,sex age ,telephone and email address that resembles the below.

    "Hiba", "M",20,1234567,"aaa@yahoo.com"

    "ahmed", "f",21,2345678,"bbb@yahoo.com"

    "ali", "M",25,3456789,"ccc@yahoo.com"
    write a program to read the file display contact information.

    ReplyDelete
  17. please help me how to get the first line of the notepad.?? to display into textbox

    ReplyDelete

 

blogger templates | Make Money Online