How to split a string with linefeed character ( LF ) as a delimiter in VB6?

Hi. I am writing a small program in VB 6.0. 
I have a string named Data and it contains few characters along with <LF> in it. ( <LF> is a new line/line feed character).
I want to split this string with <LF> as delimiter and store the tokens in an array. I tried with split function and its giving me type mismatch error. Can anyone tell me how to do it?
I am giving the pseudo-code below.
Dim Data as string
Data = "hello, how are you<LS>good morning guys <LS> hi"
Dim strarray() as stringMsgbox(Data)
strarray = split(Data, "<LS>")
When i see the Data in message box before split function, it shows up in different lines like this:
hello, how are you
good morning   guys 
hi
I want the final array strarray to be like this:   strarray(0) = "hello, how are you"
strarray(1) = "good morning   guys "
strarray(2)  = " hi"
The spaces can be as it is. Just i need the string to be delimited wherever <LS> is there.
Please help me as soon as possible. Though it is small one, i am stuck here.
Thanks in advance,
Satya.

Hello,
This forum is for VB.NET, please check the following resources
http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier
http://social.msdn.microsoft.com/Forums/vstudio/en-US/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b/where-to-post-your-vb-6-questions?forum=vbgeneral
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

Similar Messages

  • How to split a string with regular expression

    Hi.
    I need to split a string with a regular expression.
    Example
    String = "this is; a test";rune haavik;12345;
    And I want the output to be:
    "this is; a test"
    rune haavik
    12345
    If I use this code:
    private void test1()
    String str = "\"this is; a test\";rune haavik;12345;";
    int i=0;
    String[] tmp = str.split(";");
    while(i<tmp.length)
    System.out.println(tmp);
    i++;
    Then it splits also in the "" text.
    Regards
    Rune haavik

    Rune haavik:
    The most effective way to achieve the end result is, I believe, to read the characters one by one, using a flag that indicates if we are inside quotation or not.
    Well, if we are in a mind game, then the following should do.
           String[] tmp = str.split(";(?![^\"]*\";)");

  • How to split a string with a space in between?

    Hi ABAP Guru's,
    Can you please help me out? How can I split a string into two which has a space in between?
    For example: lets suppose the string is 'LA CA USA'. How can I split this string? I have to dynamically determine the number of characters before the space therefore I cannot use number constant such as 2 or 3.
    With best regards,
    Ketan

    Hi
    Try like this
    DATA : opbal TYPE p DECIMALS 2 VALUE 0.
        SELECT * FROM zs_mkpf_mseg
                        into corresponding fields of table it_opbal
                        WHERE werks =  itmat-werks
                        AND matnr = itmat-matnr
                        AND budat = s_budat-low.
      *  sort  it_opbal by budat.
      loop at it_opbal.
    read table it_opbal.
          IF it_opbal-shkzg = 'S'.
            opbal = opbal + it_opbal-menge.
          ELSEIF it_opbal-shkzg = 'H'.
            opbal = opbal + it_opbal-menge * -1.
          ENDIF.
      endloop.
        append opbal TO itab-opbal.
      ENDFORM.                    " opbal_data
    you can also use thi s
    DATA: NAMES(30)    TYPE C VALUE 'Charly, John , Peter',
          NAMES2       TYPE STRING,
          ONE(10)      TYPE C,
          TWO(10)      TYPE C,
          THREE        TYPE STRING,
          FOUR(4)      TYPE C VALUE 'FOUR',
          DELIMITER(2) VALUE ','.
    SPLIT NAMES AT DELIMITER INTO ONE TWO.
    *     ONE contains 'Charly' and TWO contains 'John , Pet'.
    *     SY-SUBRC is 4, because TWO was not large enough to
    *     accommodate the whole of the remaining string
    SPLIT NAMES AT ',' INTO ONE TWO THREE.
    *     ONE contains 'Charly', TWO contains ' John',
    *     THREE contains ' Peter'.
    SPLIT NAMES AT ', ' INTO ONE THREE TWO.
    *     ONE contains 'Charly', THREE contains 'John',
    *     TWO contains 'Peter'.
    CONCATENATE NAMES '' INTO NAMES2 SEPARATED BY SPACE.
    SPLIT NAMES2 AT DELIMITER INTO ONE TWO THREE FOUR.
    *     ONE contains 'Charly', TWO contains 'John',
    *     THREE contains 'Peter ', FOUR is empty.
    SPLIT NAMES2 AT DELIMITER INTO ONE FOUR THREE.
    *     ONE contains 'Charly', FOUR contains 'John',
    *     THREE contains 'Peter', SY-SUBRC is 4, since
    *     FOUR was not large enough (spaces are significant
    *     characters!)
    Reward all helpfull answers
    Regards
    Pavan

  • How to split a string with a delimiting regular expression like "\r"

    Hello!I am a fresh in java programming.Please don't deride my question.What I want to realize is to get the current caret lines and cols in a JTextPane. My question is :After I fetch the string content of the JTextPane and try to split it with the end-line token like "\r" or "\r\n",it always comes me an wrong position.
    here is my code:
    public void caretUpdate(CaretEvent e) {
    int ln,col;
    JTextPane textSource = (JTextPane)e.getSource();
    String sourceString = textSource.getText();
    String subString = sourceString.substring(0,
         (e.getDot() == 0) ? 0 : e.getDot()-1);
    String[] splitString = subString.split("\r",-1);
    ln = splitString.length;
    col = e.getDot() - subString.lastIndexOf("\r");
    setCaretPosition(ln,col); //display ln and col in a label
    I have got puzzled>_<.Please help me.Any help would be appreciated . (^-^)

    Swing text components always use "\n" to separate lines, not "\r" or "\r\n". When you read text in from a file or paste from the clipboard, the line separators are converted to "\n" if necessary. They save the info about what line separators were used in the source file, so if you write the text back to a file it converts them back.

  • How To Split the String for "."

    Hi Friends
    I am Using Following Code to Split one String.
    String str = "Jeetendra.choudhary";
    String[] sp_str = str.split(".");
    wdComponentApi.getMessageManager.reportSuccess(str[0]);
    wdComponentApi.getMessageManager.reportSuccess(str[1]);
    but its throwing null pointer exception. 
    when i am using following code its working fine.
    String str = "Jeetendra/choudhary";
    String[] sp_str = str.split("/");
    wdComponentApi.getMessageManager.reportSuccess(str[0]);
    wdComponentApi.getMessageManager.reportSuccess(str[1]);
    what may be the issue and how to split the string with "." ?
    Thanks & Regards
    Jeetendra

    "." is a special character.
    Use
    str.split("\\.");
    Regards
    Benjamin
    Edited by: Benjamin Hansen on Dec 29, 2009 7:52 AM

  • How to concatenate a string with single quotes

    Hi all,
        how to concatenate a string with single quotes to a variable.
    Sathya

    Hi sathyabama,
    1. simple
    2. use TILDE character <b>(`)</b>
       (just left to the '1' key)
    <b> `'mystring'`</b>
    3. just copy paste
    report abc.
    data : m(100) type c.
    concatenate `'amit mittal'` 'hello' into m separated  by space.
    write m.
    regards,
    amit m.

  • How to split the string by datetime in sql

    Hi,
    How to split the string by datetime in sql, I've a table with comments column stores comments by datetime, while selecting I want to split and show as in rows by each jobref.
    can anyone help me in this please.
    Thanks,

    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call  logged   (28/10/2014 14:56:58) xyz ..... call updated   (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call  logged   (29/10/2014 14:56:58) xyz ..... call updated   (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call  logged   (30/10/2014 14:56:58) xyz ..... call updated  
    output:
    1) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910201'
     2) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910201'
    3) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910201'
    4) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910202'
     5) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910202'
    6) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910202'
    7) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910203'
     8) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910203'
    Thanks,
    See this illustration
    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call logged (28/10/2014 14:56:58) xyz ..... call updated (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call logged (29/10/2014 14:56:58) xyz ..... call updated (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call logged (30/10/2014 14:56:58) xyz ..... call updated','Vi2910203'
    SELECT LEFT(p.u.value('.[1]','varchar(max)'),CHARINDEX(')',p.u.value('.[1]','varchar(max)'))-1) AS [Date],
    '(' + p.u.value('.[1]','varchar(max)') AS comments,
    lbiref
    FROM
    SELECT lbiref,CAST('<Root>' + STUFF(REPLACE(comments,'(','</Data><Data>'),1,7,'') + '</Data></Root>' AS XML) AS x
    FROM @callcentre c
    )t
    CROSS APPLY x.nodes('/Root/Data')p(u)
    and the output
    Date comments lbiref
    28/10/2014 14:56:14 (28/10/2014 14:56:14) xyz ..... call logged Vi2910201
    28/10/2014 14:56:58 (28/10/2014 14:56:58) xyz ..... call updated Vi2910201
    28/10/2014 14:57:41 (28/10/2014 14:57:41)xyz ..... call updated Vi2910201
    29/10/2014 14:56:14 (29/10/2014 14:56:14) xyz ..... call logged Vi2910202
    29/10/2014 14:56:58 (29/10/2014 14:56:58) xyz ..... call updated Vi2910202
    29/10/2014 14:57:41 (29/10/2014 14:57:41)xyz ..... call updated Vi2910202
    30/10/2014 14:56:14 (30/10/2014 14:56:14) xyz ..... call logged Vi2910203
    30/10/2014 14:56:58 (30/10/2014 14:56:58) xyz ..... call updated Vi2910203
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Splitting a String to a Character array

    I need to split a string to a character array. All I can find is how to split on spaces, etc.
    Can you help me?
    Thanks
    Ozmodiar

    myString = myString.toCharArray();Type mismatch! You cannot convert String myString to
    char[].
    Head loss - sorry, not switched on today ...
    char []mychars = myString.toCharArray();

  • How to create a String with a specific size?

    how to create a String with a specific size?
    For example I want to create different Strings with the size of 100 , 1000 or 63k byte?

    String are immutable so just initialize it with the number of characters you want.
    You might want to look at java.lang.StringBuffer and see if that's what you want.

  • How to print a string with out using main method??

    how to print a string with out using main method??
    if we can tell me with example?
    thanks in adavance
    raja

    Hi,
    actually there's none. The UITableView class needs to "know" the tableView's height so either it can calc <number of rows> times <row height> or it has to sum the height of each single row.
    If the row which needs to be of different size always is the first or the last row you can user a tableHeader or tableFoot view.
    Regards
    Dirk

  • How to split this string(char1)char2(char3)char4 into (char1)char2 , .. etc

    how to split this string (char1)char2(char3)char4 into (char1)char2 , (char3)char4?
    String[] result = "(char1)char2(char3)char4".split("\\(");I want :
    result[0] = "(char1)char2" and
    result[0] = "(char3)char4"
    acutally char1,char2,char3, char4 ... is in the form of the below.
    (any charactors except round brace)any charactors except round brace(any charactors except round brace)any charactors except round brace
    I prefer String.split and Pattern.compile().split.
    Edited by: iamjhkang on Feb 5, 2009 3:37 PM
    Edited by: iamjhkang on Feb 5, 2009 3:41 PM

    iamjhkang wrote:
    especially on
    ?= and ?<
    Thanks.The following:
    (?=...)   // positive look ahead
    (?!...)   // negative look ahead
    (?<=...)  // positive look behind
    (?<!...)  // negative look behindare all "look-arounds". See: [http://www.regular-expressions.info/lookaround.html]

  • How to Splilit The String Into Single Column using Comma As Delimiter ?

    How to Splilit The String Into Single Column using Comma As Delimiter ?
    using Function

    refer my thread ,code is also available see if that helps you
    error while executing the sp ORA-21779: duration not active

  • How to split a string which contents 2byte character

    hi all,
      i wanna split a string into substrings  five bits a time
    the problem is the original string may contents 2byte characters
    and if the split bit is a 2byte character we only take the first four bits.
    the 2byte character is used for the next five bits.
      so could you tell how carry is out.
    thanks in advance

    hi all,
      i wanna split a string into substrings  five bits a time
    the problem is the original string may contents 2byte characters
    and if the split bit is a 2byte character we only take the first four bits.
    the 2byte character is used for the next five bits.
      so could you tell how carry is out.
    thanks in advance

  • How to split a string - special character help need

    hai all ,
    i want to split a string
    eg: this is the text file
    dsgdsggdsgdsgds [dhana]
    hsdhsdhdsh
    sdhdshhdsh
    sdjsdhdshdsh hdshsd hsahsh
    hdfhhshs [sekaran]
    dfhdhdh
    i want to take only dhana & sekaran . which is in between the square bracket Special character "[   ] "
    thanks
    dhana

    My now classical RegExp test class:
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    * @author notivago     11/01/2005
    * @version 1.0
    public class RegTest {
        public static void main(String[] args) {
            RegTest test = new RegTest();
            // test.classFind();
            test.dharma();
            test.kharma();
        public void classFind() {
            Pattern p = Pattern.compile( "class\\s+(\\w+)(?:\\s+extends\\s+(\\w+))?(?:\\s+implements\\s+(\\w+)(?:,\\s*(\\w+))*)?\\s*\\{");
            Matcher m = p.matcher( "public class MyClass extends Esta implements Aquela, MaisUma { " );
            m.find();
            System.out.println("Match");
            System.out.println( m.group()  );
            System.out.println( "Class name: " + m.group(1) );
            System.out.println( "Extends: " + m.group(2) );
            for( int i = 3; i < m.groupCount(); i++) {
                System.out.println( "Implements: " + m.group(i) );
        public void stringBreak() {
            Pattern p = Pattern.compile( "([0-9]++\\s++)");
            Matcher m = p.matcher( "1111       22222       333333       444    5     " );
            for( int i = 0; m.find(); i++ ) {
                System.out.println( "Match "+ i + ": [" + m.group(0) + "]" );
        public void dharma() {
            Pattern p = Pattern.compile( "(dhana|sekaran)");
            Matcher m = p.matcher( "dsgdsggdsgdsgds [dhana]\nhsdhsdhdsh\nsdhdshhdsh\nsdjsdhdshdsh hdshsd hsahsh\nhdfhhshs [sekaran]\ndfhdhdh" );
            for( int i = 0; m.find(); i++ ) {
                System.out.println( "Match "+ i + ": " + m.group(0)  );
        public void kharma() {
            Pattern p = Pattern.compile( "[\\[](dhana|sekaran)[\\]]");
            Matcher m = p.matcher( "dsgdsggdsgdsgds [dhana]\nhsdhsdhdsh\nsdhdshhdsh\nsdjsdhdshdsh hdshsd hsahsh\nhdfhhshs [sekaran]\ndfhdhdh" );
            for( int i = 0; m.find(); i++ ) {
                System.out.println( "Match "+ i + ": \t" + m.group(0)  );
                System.out.println( "Sub-match "+ i + ": \t" + m.group(1)  );
    }May the code be with you.

  • How to split the string from character position.

    HI ALL,
    I need to split the string like this.
    example:
    String = "HelloWorld"
    mid("HelloWorld", 2, 5);
    it should print   "ello"
    menas mid is functiuon it will split "HelloWorld" from 2nd character to 5th character and prints "ello".
    This one how to do in labview.
    Regards
    Punith

    String Subset is the function you are looking for.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for

  • Unable to Partition Drive - 3TB Fusion Drive

    Hi, I have been trying to create a Windows Partition using Boot Camp: I get the error message "Your disk could not be partitioned" as soon as I hit Install. I then tried to Partition the drive in Disk Utility and get the error message "Partition fail

  • PSE 8.0 - Catalogue Problems

    G/L, Many thanks for your advice but I still have a problem with PSE.  I use the Program principally as a Photo data base and for the creation of  family Albums and associated slide shows with music. As my PC Solid State C: drive was reaching capacit

  • Inherited fields and methods shown with the class own fields and methods

    In each subclass page, javadoc includes the fields and methods of the superclass as if they were declared in the subclass. However the methods inherited from Object are shown in a separate box. Is there a way to make javadoc group all inherited field

  • Student and teacher design standard installation issues for photoshop

    I recently purchased a STUDENT AND TEACHER LICENSING package: ADOBE CREATIVE SUITE 5.5 DESIGN STANDARD. I installed everything and everything opens and works except Photoshop. When I try to open it it says, "Some of the application cxomponents are mi

  • Software download failed n96

    hi all,i cannot load some software from the disc or from nokia downloads. n series system utilities and nokia software updater fail to load.running vista, any ideas would be appreciated thanks