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 File Content and Store it in string Line by Line

Read File Content and Store it in string Line by Line

Scheduled Pinned Locked Moved Visual Basic
help
3 Posts 3 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
    aaraaayen
    wrote on last edited by
    #1

    Hi All, I am developing project in MS-Access with VBA. In MS-Access I have 1 form , which has 1 command Button. For me, When I click the button, it should take and read texfile from path c: and i need to go through loop until all the lines are completed in that file. So I need to Read the textfile one by one line and store that particular line in string and in that string i have to search whether that line starts with 1 or 2. If it starts with 1 i have to give different command or if its starts with 2 then different command. Likewise i need to check for all the lines in that textfile. I tried it in different way, but didnt help. Kindly help me. Its very urgent. Thanks in advance. Regards,

    X J 2 Replies Last reply
    0
    • A aaraaayen

      Hi All, I am developing project in MS-Access with VBA. In MS-Access I have 1 form , which has 1 command Button. For me, When I click the button, it should take and read texfile from path c: and i need to go through loop until all the lines are completed in that file. So I need to Read the textfile one by one line and store that particular line in string and in that string i have to search whether that line starts with 1 or 2. If it starts with 1 i have to give different command or if its starts with 2 then different command. Likewise i need to check for all the lines in that textfile. I tried it in different way, but didnt help. Kindly help me. Its very urgent. Thanks in advance. Regards,

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      here is C# example, use any converter for VB

      string[] lines = File.ReadAllLines( <FILEPATH> );

      then make a loop that will check every line hope this will help

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

      1 Reply Last reply
      0
      • A aaraaayen

        Hi All, I am developing project in MS-Access with VBA. In MS-Access I have 1 form , which has 1 command Button. For me, When I click the button, it should take and read texfile from path c: and i need to go through loop until all the lines are completed in that file. So I need to Read the textfile one by one line and store that particular line in string and in that string i have to search whether that line starts with 1 or 2. If it starts with 1 i have to give different command or if its starts with 2 then different command. Likewise i need to check for all the lines in that textfile. I tried it in different way, but didnt help. Kindly help me. Its very urgent. Thanks in advance. Regards,

        J Offline
        J Offline
        Justin Porteous
        wrote on last edited by
        #3

        Try this... Dim FILE_NAME As String = "C:\test.txt" Dim tmpLine As String = "" If System.IO.File.Exists(FILE_NAME) = True Then Dim objReader As New System.IO.StreamReader(FILE_NAME) Do While objReader.Peek() <> -1 tmpLine = objReader.ReadLine() If Mid(tmpLine, 1, 1) = "1" Then ' Your code for command 1 ElseIf Mid(tmpLine, 1, 1) = "2" Then ' Your code for command 2 Else ' Your code for anything else End If Loop Else MsgBox("File Does Not Exist") End If

        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