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 Studio
  4. Read text file and split the string to specific column in datagridview

Read text file and split the string to specific column in datagridview

Scheduled Pinned Locked Moved Visual Studio
saleshelptutorialquestion
2 Posts 2 Posters 10 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.
  • U Offline
    U Offline
    User 13605652
    wrote on last edited by
    #1

    Hi, Please help me how to add the blue color text to datagridview here is my code:

        Dim FileLine As String
        Dim LineLength As Integer
    
    
        Using sr As New StreamReader("C:\\Users\\WIN 7\\Desktop\\rmsbp050\_09032018.txt")
            While Not sr.EndOfStream
    
    
                FileLine = sr.ReadLine()
                LineLength = FileLine.Length
    
    
    
    
    
    
                If LineLength = 59 Then
    
    
                    DataGridView1.Rows.Add(FileLine.ToString, sr.ReadLine() & vbNewLine, sr.ReadLine() & vbNewLine & vbNewLine, sr.ReadLine() & vbNewLine & vbNewLine & vbNewLine)
    
    
                End If
    
    
            End While
        End Using
    

    Here is the sample text file : BANK NAME 15 CUSTOMER INFORMATION SYSTEM *RMR100 * PAGE NO 1 CTL 2 000 PNB SAVINGS BANK MONDAY PROCESS DATE 09/03/18 CTL 3 000 ACTIVITY *RM 100* PROCESS THRU 09/03/18 CTL 4 0000 CURRENT DATE 09/03/18 BRANCH 0000 - PNB SAVNGS BANK CUSTOMER NAME CUSTOMER NBR CUSTOMER INITIATED? TRAN DATE TIME FIELD DESCRIPTION ACT TRAN ID AFTER EMPLOYEE TERMINAL LST MNT DATE LST MNT TIME BEFORE KEY CO, CARLOS VERA 00000004676090 N 09/03/18 10:21:42 RESP BR MNT RM1P 0000 15-000-1027993 B112 03/29/2017 02:16:23 09/03/18 10:21:42 SRC OF FUNDS MNT RM1P PENSION 15-000-1027993 B112 03/29/2017 02:16:23 SSS PENSIO 09/03/18 10:21:42 ACT OFFICER ID MNT RM1P 869376 15-000-1027993 B112 03/29/2017 02:16:23 00305294 09/03/18 10:21:42 DT LST RM ACTV MNT RM1P 20180903 15-000-1027993 B112 03/29/2017 02:16:23 20170329 09/03/18 10:21:42 CL RISK CLASS MNT RM1P B 15-000-1027993 B112 03/29/2017 02:16:23 C 09/03/18 10:21:42 CHK USER ID MNT RM1P 1027993 15-000-1027993 B112 03/29/2017 02:16:23 00144193 09/03/18 10:21:42 PH NBR MNT RM1P . 15-000-1027993 B112 03/29/2017 02:16:2

    V 1 Reply Last reply
    0
    • U User 13605652

      Hi, Please help me how to add the blue color text to datagridview here is my code:

          Dim FileLine As String
          Dim LineLength As Integer
      
      
          Using sr As New StreamReader("C:\\Users\\WIN 7\\Desktop\\rmsbp050\_09032018.txt")
              While Not sr.EndOfStream
      
      
                  FileLine = sr.ReadLine()
                  LineLength = FileLine.Length
      
      
      
      
      
      
                  If LineLength = 59 Then
      
      
                      DataGridView1.Rows.Add(FileLine.ToString, sr.ReadLine() & vbNewLine, sr.ReadLine() & vbNewLine & vbNewLine, sr.ReadLine() & vbNewLine & vbNewLine & vbNewLine)
      
      
                  End If
      
      
              End While
          End Using
      

      Here is the sample text file : BANK NAME 15 CUSTOMER INFORMATION SYSTEM *RMR100 * PAGE NO 1 CTL 2 000 PNB SAVINGS BANK MONDAY PROCESS DATE 09/03/18 CTL 3 000 ACTIVITY *RM 100* PROCESS THRU 09/03/18 CTL 4 0000 CURRENT DATE 09/03/18 BRANCH 0000 - PNB SAVNGS BANK CUSTOMER NAME CUSTOMER NBR CUSTOMER INITIATED? TRAN DATE TIME FIELD DESCRIPTION ACT TRAN ID AFTER EMPLOYEE TERMINAL LST MNT DATE LST MNT TIME BEFORE KEY CO, CARLOS VERA 00000004676090 N 09/03/18 10:21:42 RESP BR MNT RM1P 0000 15-000-1027993 B112 03/29/2017 02:16:23 09/03/18 10:21:42 SRC OF FUNDS MNT RM1P PENSION 15-000-1027993 B112 03/29/2017 02:16:23 SSS PENSIO 09/03/18 10:21:42 ACT OFFICER ID MNT RM1P 869376 15-000-1027993 B112 03/29/2017 02:16:23 00305294 09/03/18 10:21:42 DT LST RM ACTV MNT RM1P 20180903 15-000-1027993 B112 03/29/2017 02:16:23 20170329 09/03/18 10:21:42 CL RISK CLASS MNT RM1P B 15-000-1027993 B112 03/29/2017 02:16:23 C 09/03/18 10:21:42 CHK USER ID MNT RM1P 1027993 15-000-1027993 B112 03/29/2017 02:16:23 00144193 09/03/18 10:21:42 PH NBR MNT RM1P . 15-000-1027993 B112 03/29/2017 02:16:2

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      Wouldn't you like to ask it in some of the VB Forums?

      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