Question:

How can you store text data on a computer from visual basic

by  |  earlier

0 LIKES UnLike

I'm working on a game with some friends of mine, and I was thinking about something similar to a save file. I want to have visual basic store a text file in a place the user can select containing the values for several variables, then have the program open the file again at a later date to load the data. is there any way that this would be possible?

 Tags:

   Report

1 ANSWERS


  1. Here is another one.....VB2008or VB2008Express

    Add a textbox, button and a SaveFileDialog...

    Cut and paste this into the code pane:

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim filename As String

    Try

    With SaveFileDialog1

    .AddExtension = True

    .CheckPathExists = True

    .CreatePrompt = False

    .OverwritePrompt = True

    .ValidateNames = True

    .ShowHelp = True

    .DefaultExt = "txt"

    .FileName = filename

    .Filter = _

    "Text files (*.txt)|*.txt|" & "All files|*.*"

    .FilterIndex = 1

    If .ShowDialog() = Windows.Forms.DialogResult.OK Then

    My.Computer.FileSystem.WriteAllText(.F... TextBox1.Text, False)

    End If

    End With

    Catch ex As Exception

    MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)

    End Try

    End Sub

    End Class

    : )

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.