How to write string to a text file in VB.NET

2 Answers

0 votes
Imports System.IO

Module Module1

    Sub Main()

        Try

            File.WriteAllText("d:\\file.txt", "VB is a great simple programming language")

        Catch ex As Exception

            Console.WriteLine(ex.Message)

        End Try

    End Sub

    'run:
    ' 
    'file.txt:
    '--------
    'VB is a great simple programming language

End Module

 



answered Jul 24, 2015 by avibootz
0 votes
Imports System.IO

Module Module1

    Sub Main()

        Dim s As String = "VB is a great simple programming language" 

        Try

            File.WriteAllText("d:\\file.txt", s)

        Catch ex As Exception

            Console.WriteLine(ex.Message)

        End Try

    End Sub

    'run:
    ' 
    'file.txt:
    '--------
    'VB is a great simple programming language

End Module

 



answered Jul 24, 2015 by avibootz

Related questions

1 answer 199 views
1 answer 286 views
1 answer 223 views
1 answer 236 views
1 answer 300 views
1 answer 232 views
1 answer 244 views
...