Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the StringWriter class
Here, we are going to demonstrate the StringWriter class in VB.Net.
Submitted by Nidhi, on January 06, 2021
Here, we will use WriteLine() method of StringWriter class to write data into the stream and then print saved information on the console screen.
Program/Source Code:
The source code to demonstrate the StringWriter class is given below. The given program is compiled and executed successfully.
'Vb.Net program to demonstrate StringWriter class.
Imports System.IO
Imports System.Text
Module Module1
Sub Main()
Dim obj As New StringWriter(New StringBuilder())
obj.WriteLine(vbTab & "It is a book.")
obj.WriteLine(vbTab & "It is a table.")
obj.WriteLine(vbTab & "It is a fan.")
obj.Flush()
obj.Close()
Console.WriteLine("Information:")
Console.WriteLine(obj)
End Sub
End Module
Output:
Information:
It is a book.
It is a table.
It is a fan.
Press any key to continue . . .
Explanation:
In the above program, we created a class module Module1 that a Main() function. The Main() method is the entry point of the program, here we write the data into the stream using WriteLine() method of StringWriter class and then print saved information on the console screen.
VB.Net StringReader, StringWriter, Stream Programs »
ADVERTISEMENT
ADVERTISEMENT