Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. read write file

read write file

Scheduled Pinned Locked Moved Visual Basic
c++iostutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • A Anonymous

      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

      D Offline
      D Offline
      dynamic
      wrote on last edited by
      #2

      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


      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups