read write file
-
I'm c++ programmer.. How to convert the following C++ code to VB?
**c++** char str1[1024]; ifstream fin("c:\\file1.txt",ios::in); ofstream fout("c:\\file2.txt",ios::out); while (!fin.eof()) { fin.getline(str1,1024,'|'); // reading line str1[strlen(str1)] = NULL; fout< the following code is a basic I/O file in C++. I wanna know the basic read write to file in VB.. I found something but kind of confused me.. Could you explain how.. thanks
-
I'm c++ programmer.. How to convert the following C++ code to VB?
**c++** char str1[1024]; ifstream fin("c:\\file1.txt",ios::in); ofstream fout("c:\\file2.txt",ios::out); while (!fin.eof()) { fin.getline(str1,1024,'|'); // reading line str1[strlen(str1)] = NULL; fout< the following code is a basic I/O file in C++. I wanna know the basic read write to file in VB.. I found something but kind of confused me.. Could you explain how.. thanks
well you could write to a file / create and write in vb.net like this... VbCode:
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim writer As IO.StreamWriter = New IO.StreamWriter(New IO.FileStream("D:\\my.html", IO.FileMode.OpenOrCreate)) writer.Write(RichTextBox1.Text) writer.Close() Process.Start("D:\\my.html") End Sub
or to read / still be able to write .... VbCode:
Private Sub Button2\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim reader As New IO.StreamReader(New IO.FileStream("D:\\my.html", IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite)) While Not reader.Peek RichTextBox1.AppendText(reader.ReadLine & Environment.NewLine) End While reader.Close() End Sub
hope it helps Vb:
Public Function TwinsOnWay(ByVal twins As String) As String
Select Case twins
Case "Gender"
Return "Two Girls"
End Select
End Function