saving an answer

ok. how can i make vb ask a question and save the answer in a text file so i can access it with this code.

Dim Instring As String

Dim stream_reader As New IO.StreamReader("textfile.txt")

Instring = stream_reader.ReadToEnd()

stream_reader.Close()




Answer this question

saving an answer

  • Omer kamal

    because then i can refer to it later

  • akhin

    Hi,

    simply use the good old fashioned "Inputbox" control/command!!

    ...
    Dim sText As String = InputBox("Enter some text")
    If String.Empty.Equals(sText) then return
    If sText.length <= 0 Then Return
    Dim oTW As IO.TextWriter
    Try
    oTW = New IO.StreamWriter("c:\text.txt")
    oTW.WriteLine(s)
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    Finally
    If oTW isnot Nothing then
    oTW.Flush()
    oTW.Close()
    End If
    oTW = Nothing
    End Try
    ...

    Hope that helps,
    BavBoy

  • Bertil Syamken - MSFT

    That's a pretty broad question. Try breaking it down into logical steps, and asking for the steps you can't answer yourself. Where do the questions come from Why do you want to store the answer at all



  • Colin Millar

    thanks very much!!!

  • Richard Williams

    ok if you look above you can see a load of code.

    that should save text that i put in an inputbox yes.

    but i have a erroe on the bit where it says

    If oTW Is Not Nothing Then

    it says

    "is" requires operands that have reference type but, this operand has the value type `interger.

    how do i fix this



  • jrober64

    Input box



  • saving an answer