Results 1 to 5 of 5

Thread: [RESOLVED] Search in a string

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    24

    Resolved [RESOLVED] Search in a string

    Hello All,

    I have a textfile like
    A'''Equipment room'''10'''Primary'''10'''5.0'''23'''2323'''2.60E-02'''1.6''
    B'''Control room'''25'''Secundary'''2.0'''N/A'''23'''23'''N/A'''N/A'''6.53E-03'''
    C'''Equipment room'''10'''Secundary'''2.0'''N/A'''23'''23'''N/A'''N/A'''1.63E-02'''
    D'''Equipment room'''25'''Secundary'''2.0'''N/A'''23'''23'''N/A'''N/A'''6.53E-03'''

    the data are seperated by '''

    I am importing the data row by row.
    Row_1 = A'''Equipment room'''10'''Primary'''10'''5.0'''23'''2323'''2.60E-02'''1.6''
    Row_2= B'''Control room'''25'''Secundary'''2.0'''N/A'''23'''23'''N/A'''N/A'''6.53E-03'''

    I need the data from each row in a listview.
    like A (should be in the 1st column)
    Equipment room (should be in the 2nd column)
    and so on

    I know how to get it into the listview but I don't know how to seperate the data before

  2. #2
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: Search in a string

    For each line in the text file split by your delimiter '''

    Then for each item in the array add it into the correct column. So something like this maybe...
    VB Code:
    1. Dim parser() as String = Split(LINE_FROM_FILE, "'''")

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    24

    Re: Search in a string

    ??????
    I am a net beginner.
    Do you have a little bit more code?

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Search in a string

    what he is saying, is use the split method to split the string into an array of strings. an array uses an index (a number) to access the different entries in the array. Also an array starts with an index of 0.

    so if you were to do
    VB Code:
    1. 'WHERE DATA_LINE EQUALS THE LINE YOU READ IN FROM THE TEXT FILE
    2. Dim MyData() as string = string.split(DATA_LINE,"'''")
    this creates an array called MyData that will contain all the elements from the DATA_LINE, but split by the '''

    so A would be at MyData(0), Equipment room would be at MyData(1), etc...

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    24

    Resolved Thank

    It's working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width