CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: data saving

  1. #1
    Join Date
    Nov 1999
    Posts
    1

    data saving

    Hello people,
    i've got a problem.
    How my name says I'm a dummie in Visual Basic.
    And I don´t find someone who helps me.
    My problem:
    How can I save datas in VB on the harddisk ?
    For example I want to save a highscore.
    Is there a possibility to save the datas without
    a database like Acces ?

    Can someone help me ?
    Perhaps you can send me documentations or good
    links, or of course the best way cou can
    discribe it me. (I´m German, so please in a
    easy English or in German)

    Thank you very much,

    Marcel


  2. #2
    Guest

    Re: data saving

    haha


  3. #3
    Guest

    Re: data saving

    Create an empty file using Notepad and save it as "C:\myTest.txt". Open VB and place 2 Command Buttons on the form. Open Code Window for Form1 and Paste the following code:

    private Sub Command1_Click()
    Dim intFreeFile as Integer
    Dim TextLine as string
    intFreeFile = FreeFile
    Open "C:\myData.txt" for Output as #intFreeFile ' Open file.

    Write #intFreeFile, "Hello World", 234 ' Write comma-delimited data.
    Write #intFreeFile, ' Write blank line.
    Write #intFreeFile, "You are not dummie if you are trying to do this"
    Close #intFreeFile
    End Sub

    private Sub Command2_Click()
    Dim intFreeFile as Integer
    Dim TextLine as string
    intFreeFile = FreeFile
    Open "C:\myData.txt" for input as #intFreeFile ' Open file.
    Do While Not EOF(intFreeFile) ' Loop until end of file.
    Line input #intFreeFile, TextLine ' Read line into variable.
    Debug.print TextLine ' print to the Immediate window.
    Loop
    Close #intFreeFile ' Close file.

    End Sub




    Run project and click on Command1, then on Command2. If you now open "C:\myTest.txt" you'll see, that it's not empty anymore. This is just the beginning. After that you can write the contents of the text box to the file , and display the contents of the file in a text box or in a grid.
    Hope this helps
    Vlad


  4. #4
    Join Date
    Nov 1999
    Location
    Newfoundland , Canada
    Posts
    1

    Re: data saving

    You can create a datafile using:

    e.g. Private Sub Form_Load()
    open "path\filename" for Input As #1

    for i = 1 to arraynumber step 1
    Write #1, variablename, variablename

    just an example of something that may help


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