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. Finding the End Of File

Finding the End Of File

Scheduled Pinned Locked Moved Visual Basic
questioncsharp
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.
  • D Offline
    D Offline
    DxSolo
    wrote on last edited by
    #1

    hey i have a project where i need to read from a text file but i will never know how long it is. It is basically a list of numbers. I read them in and store them in a collection but how do i know when the end of file is? this is in VB.Net

    D 1 Reply Last reply
    0
    • D DxSolo

      hey i have a project where i need to read from a text file but i will never know how long it is. It is basically a list of numbers. I read them in and store them in a collection but how do i know when the end of file is? this is in VB.Net

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

      this should help , make sure to put your text file's location where it currently says C:\mytest.txt . VbCode:


      Imports System.IO
      '/// at the top of your form's code window ^^^^.
      '/////////////////////////////////////////////
      Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
      Dim sReader As StreamReader = New StreamReader(New FileStream("C:\mytest.txt", FileMode.Open, FileAccess.Read))
      Dim x As Integer = sReader.BaseStream.Length
      MessageBox.Show("The Length of the text file is: " & x & " Characters")
      While Not sReader.Peek
      Console.WriteLine(sReader.ReadLine)
      End While
      sReader.Close()
      End Sub


      hope that 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