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. How to display second line if the first line in text file is meet the condition

How to display second line if the first line in text file is meet the condition

Scheduled Pinned Locked Moved Visual Basic
csharptutorial
3 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.
  • T Offline
    T Offline
    Tram88
    wrote on last edited by
    #1

    Dear All, Would you please tell me how to display second line if the first line in text file is meet the condition. I am using VB.NET. I would appreciate your helps very much,

    C 1 Reply Last reply
    0
    • T Tram88

      Dear All, Would you please tell me how to display second line if the first line in text file is meet the condition. I am using VB.NET. I would appreciate your helps very much,

      C Offline
      C Offline
      CWIZO
      wrote on last edited by
      #2

      You open the file, read the first line compare it to the condition, if it passses then you display the second line. What part is giving you problems? -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

      T 1 Reply Last reply
      0
      • C CWIZO

        You open the file, read the first line compare it to the condition, if it passses then you display the second line. What part is giving you problems? -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

        T Offline
        T Offline
        Tram88
        wrote on last edited by
        #3

        Dear CWIZO, Here is my code below, with this code, I can read how many lines that met the condition, but I can not read the second line. Can you help me out. I would appreciate your potential helps very much, Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click Dim Start As String = "Start" Dim intTotalCount As Integer intTotalCount = CountStringInFile(strFile, Start) **<--HERE, I CAN READ HOW MANY LINE MET THE CONDITION** end Sub Private Function CountStringInFile(ByVal FilePath As String, ByVal StringToLookFor As String) As Integer Dim strContent As String = "" 'Get a StreamReaderclass that can be used to read the file Dim objStreamReader As StreamReader Dim intCount As Integer Dim intCountahead As Integer = 1 objStreamReader = File.OpenText(FilePath) While objStreamReader.Peek <> -1 strContent = objStreamReader.ReadLine intCount += CountLineByLine(strContent, StringToLookFor) End While 'Close the stream objStreamReader.Close() objStreamReader = Nothing Return intCount End Function Private Function CountLineByLine(ByVal vstr As String, ByVal strToSearch As String) As Integer Dim intIndex As Integer Dim intCount As Integer = 0 intIndex = InStr(vstr, strToSearch) While intIndex > 0 intCount += 1 intIndex = InStr(intIndex + 1, vstr, strToSearch) End While Return intCount 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