.Split() Function

Am I using the .Split() function wrong? I have a DataGrid widget that returns the selected row. I am trying to parse the selected row string so I can access the values to display.

Here is a screenshot of how I am using it:

I am currently just sending the data to ErrorMessage.Text to view the output before I start setting it to my actual text boxes. The SelectedSKURow is my custom property string that my DataGrid SelectedRow is binded to. 

The SelectedRow returns "ID|Name|Qty1|Qty2" which is why I am trying to split by the "|" character. I originally had stringSplit = SelectedSKURow.Split("|") but that also wasn't splitting anything. It just sets the whole selected row string as stringSplit[1].

Parents
  • Hi Caroline, 

    Please try the following

    dim myString as string;
    myString = "ID|Name|Qty1|Qty2";
    
    dim delimstr as string;
    dim stringsplit[4] as string;
    dim split[1] as System.Char;
    delimstr = "|"; 
    split = delimstr.ToCharArray();
    stringsplit = myString.Split(split);
    
    LogMessage("value on position 1: "+stringsplit[1]);
    LogMessage("value on position 2: "+stringsplit[2]);
    LogMessage("value on position 3: "+stringsplit[3]);
    LogMessage("value on position 4: "+stringsplit[4]);

    The result should be 

Reply
  • Hi Caroline, 

    Please try the following

    dim myString as string;
    myString = "ID|Name|Qty1|Qty2";
    
    dim delimstr as string;
    dim stringsplit[4] as string;
    dim split[1] as System.Char;
    delimstr = "|"; 
    split = delimstr.ToCharArray();
    stringsplit = myString.Split(split);
    
    LogMessage("value on position 1: "+stringsplit[1]);
    LogMessage("value on position 2: "+stringsplit[2]);
    LogMessage("value on position 3: "+stringsplit[3]);
    LogMessage("value on position 4: "+stringsplit[4]);

    The result should be 

Children
No Data