Get Items from String

VB.net
I need to get the third and forth item from a string. The string varies in items within delimiter and total number of delimiters.
My delimiter is :
MyString = "ALL:0:Red:11Green:31:Blue:217"
MyItems = "Red:11"
Also, if elements 3 and 4 are not there, messagebox.show("Items don't exist.")
Thanks,
ADawn
ADawn

There is a : between 11 and Green.
"ALL:0:Red:11:Green:31:Blue:217"
ADawn
ADawn
Then it's even easier.
Option Strict On
Option Explicit On
Option Infer Off
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim s As String = "ALL:0:Red:11:Green:31:Blue:217"
Dim parts As List(Of String) = s.Split(":"c).ToList
Dim allLabel As String = parts(0)
Dim allValue As String = parts(1)
Dim redLabel As String = parts(2)
Dim redValue As String = parts(3)
Dim greenLabel As String = parts(4)
Dim greenValue As String = parts(5)
Dim blueLabel As String = parts(6)
Dim blueValue As String = parts(7)
MsgBox(String.Format("{0}:{1}", redLabel, redValue))
End Sub
End Class
“If you want something you've never had, you need to do something you've never done.”
Don't forget to mark
helpful posts and answers
! Answer an interesting question? Write a
new article
about it! My Articles
*This post does not reflect the opinion of Microsoft, or its employees.

Similar Messages

  • Get Items from limited list by providing username and password - C#

    I'm using the code at the following link in order to get items from SharePoint list,
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.list.getitems.aspx
    I have a SharePoint list that limited to certain users.
    How can I provide by this code (or else) a username and password and log in as a different user who has access to this SharePoint list and get its items?
    Thanks!

    Sorry, previous post didn't see you were using client object model.
    Service.Credentials = (create new credentials passing username and password)
    ICredentials credentials = new NetworkCredential("Joe",SecurelyStoredPassword,"mydomain");
                math.Credentials = credentials
    Thanks!
    Actually, my full question already posted here:
    http:  //sharepoint.stackexchange.com/questions/84917/c-why-impersonation-is-expired-while-clientcontext-executequery-is-performe
    but I was unable to post it here as a new user (images, links, lenght ...) even the link above I was need to insert spaces after "http:" to be able to post it.
    Anyway, I don't know "client object model." am I using it?
    You mentioned "Service.Credentials", What do you mean "Service"?

  • Get chars from string of numerals

    here is what I would like to accomplish:
    Put the last four integers of the systemDate into a variable so I can do some math with them.
    Thanks.

    Excellent.  Thank you for the info.  Very helpful.
    Dewey
    From: jchunick [email protected]
    Sent: Friday, June 03, 2011 4:20 PM
    To: Dewey Parker
    Subject: Re: get chars from string of numerals
    This is a post I made for the wiki which should help: http://director-online.com/dougwiki/index.php?title=Undocumented_Lingo#the_systemDate

  • Get items from ews and open in Outlook desktop client

    Hi,
    I have a webapplication with a screen that shows the last unread items from ews in the browser. When a user clicks the item I open the mail in owa. 
    Is it possible to retrieve mail items with the ews service and the open Outlook desktop client from the browser and open a message that I received?
    Regards
    Danny

    You have to use the HexEntryId not the EWSId eg you can get it by either using convertId and asking for the HexEntryId format or just use the PR_EntryId extended property eg
    ItemView ivItemView = new ItemView(1);
    PropertySet itemPropset = new PropertySet(BasePropertySet.FirstClassProperties);
    ExtendedPropertyDefinition PR_EntryId = new ExtendedPropertyDefinition(0x0FFF, MapiPropertyType.Binary);
    itemPropset.Add(ContactSchema.StoreEntryId);
    itemPropset.Add(PR_EntryId);
    ivItemView.PropertySet = itemPropset;
    FolderId fid = new FolderId(WellKnownFolderName.Contacts, new Mailbox("[email protected]"));
    FindItemsResults<Item> fiResults = service.FindItems(fid, ivItemView);
    if (fiResults.Items.Count == 1)
    if (fiResults.Items[0] is Contact) {
    Contact cntContact = (Contact)fiResults.Items[0];
    Byte[] EntryVal = null;
    String HexEntryId = "";
    if(cntContact.TryGetProperty(PR_EntryId,out EntryVal)){
    HexEntryId = BitConverter.ToString(EntryVal).Replace("-","");
    Cheers
    Glen

  • How to get item from dictionary

    I created dictionary and create two variables in SharePoint Designer 2013 workflow:
    Name: Accept; Type: string; Value:  application/json;odata=verbose;
    Name: Content-Type ; Type: string; Value: application/json;odata=verbose;
    Output variable: JSonRequestHeader.
    I called HTTP web service:
    https://xxxxxx/_api/web/Lists/getbytitle('WorkflowTaskList')/items?$select=ID
    then Get d/results from Variable:JSonResponse(Output to Variable: allItemsData)
    then Count Items in Variable: allItemsData(Output to Variable: allItemsIDData)
    These Actions worked well.
    How I can get item’s ID number from dictionary?
    Get d/results[%Variable: index%] or Get d/results([%Variable: index%]) where
    index = 0,1,2….. did not extract ID numbers from dictionary
    I would be grateful for any help.
    bnossov

    Andy,
    Get d/results/[your index variable]/id or Get d/results/[your index variable]/ID
    does not work.
    The web service
    https://xxxxxx/_api/web/Lists/getbytitle('WorkflowTaskList')/items?$select=ID
    gives me:
     <?xml version="1.0" encoding="utf-8"
    ?>
    <feed xml:base=https://xxxxxxxx/_api/ xmlns="http://www.w3.org/2005/Atom"
    xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
    xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
      <id>07ac172a-107a-4058-bdc5-8dead90a39ec</id>
      <title
    />
      <updated>2014-04-16T20:51:04Z</updated>
    <entry m:etag=""2"">
      <id>de27ea13-0f4c-4e94-97de-2ccb535ad8f4</id>
      <category
    term="SP.Data.WorkflowTaskListListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link
    rel="edit" href="Web/Lists(guid'd840c4a5-5692-430b-8e7a-a435f8b6e8c0')/Items(62)" />
      <title
    />
      <updated>2014-04-16T20:51:04Z</updated>
    <author>
      <name
    />
      </author>
    <content type="application/xml">
    <m:properties>
      <d:Id m:type="Edm.Int32">62</d:Id>
      <d:ID m:type="Edm.Int32">62</d:ID>
      </m:properties>
      </content>
      </entry>
    <entry m:etag=""3"">
      <id>3864b871-36eb-4594-b8c4-2bae909ea1ff</id>
      <category
    term="SP.Data.WorkflowTaskListListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link
    rel="edit" href="Web/Lists(guid'd840c4a5-5692-430b-8e7a-a435f8b6e8c0')/Items(63)" />
      <title
    />
      <updated>2014-04-16T20:51:04Z</updated>
    <author>
      <name
    />
      </author>
    <content type="application/xml">
    <m:properties>
      <d:Id m:type="Edm.Int32">63</d:Id>
      <d:ID m:type="Edm.Int32">63</d:ID>
      </m:properties>
      </content>
      </entry>
    <entry m:etag=""3"">
      <id>b78c4a1a-5be4-40b1-98e6-98f702602056</id>
      <category
    term="SP.Data.WorkflowTaskListListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link
    rel="edit" href="Web/Lists(guid'd840c4a5-5692-430b-8e7a-a435f8b6e8c0')/Items(64)" />
      <title
    />
      <updated>2014-04-16T20:51:04Z</updated>
    <author>
      <name
    />
      </author>
    <content type="application/xml">
    <m:properties>
      <d:Id m:type="Edm.Int32">64</d:Id>
      <d:ID m:type="Edm.Int32">64</d:ID>
      </m:properties>
      </content>
      </entry>
     </feed>
    I need to get d:ID value.
    Thanks in advance for your help.
    bnossov

  • How to get items from a list that has more items than the List View Threshold?

    I'm using SharePoints object model and I'm trying to get all or a subset of the items from a SharePoint 2010 list which has many more items than the list view threshold (20,000+) using the SPList.GetItems() method. However no matter what I do the SPQueryThrottledException
    always seems to be thrown and I get no items back.
    I'm sorting based on the ID field, so it is indexed. I've tried setting the RowLimit property on the SPQuery object(had no effect). I tried specifying the RowLimit in the SPQuerys ViewXml property, but that still throws a throttle exception. I tried using the
    ContentIterator as defined here:http://msdn.microsoft.com/en-us/library/microsoft.office.server.utilities.contentiterator.aspx,
    but that still throws the query throttle exception. I tried specifying the RowLimit parameter in the ProcessListItems functions, as suggested by the first comment here:http://tomvangaever.be/blogv2/2011/05/contentiterator-very-large-lists/,
    but it still throws the query throttle exception. I tried using GetDataTable instead, still throws query throttle exception. I can't run this as admin, I can't raise the threshold limit, I can't raise the threshold limit temporarily, I can't override the lists
    throttling(i.e. list.EnableThrottling = false;), and I can't override the SPQuery(query.QueryThrottleMode = SPQueryThrottleOption.Override;). Does anyone know how to get items back in this situation or has anyone succesfully beaten the query throttle exception?
    Thanks.
    My Query:
    <OrderBy>
        <FieldRef Name='ID' Ascending='TRUE' />
    </OrderBy>
    <Where>
        <Geq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Geq>
    </Where>
    My ViewXml:
    <View>
        <Query>
            <OrderBy><FieldRef Name='ID' Ascending='TRUE' /></OrderBy>
            <Where>
                <Geq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Geq>
            </Where>
        </Query>
        <RowLimit>2000</RowLimit>
    </View>
    Thanks again.

    I was using code below to work with 700000+ items in the list.
    SPWeb oWebsite = SPContext.Current.Web;
    SPList oList = oWebsite.Lists["MyList"];
    SPQuery oQuery = new SPQuery();
    oQuery.RowLimit = 2000;
    int intIndex = 1;
    do
    SPListItemCollection collListItems = oList.GetItems(oQuery);
    foreach (SPListItem oListItem in collListItems)
    //do something oListItem["Title"].ToString()
    oQuery.ListItemCollectionPosition = collListItems.ListItemCollectionPosition;
    intIndex++;
    } while (oQuery.ListItemCollectionPosition != null);
    Oleg
    Hi Oleg, thanks for replying.
    The problem with the code you have is that your SPQuery object's QueryThrottleMode is set to default. If you run that code as a local admin no throttle limits will be applied, but if you're not admin you will still have the normal throttle limits. In my
    situation it won't be run as a local admin so the code you provided won't work. You can simulate my dilemma by setting the QuerryThrottleMode  property to SPQueryThrottleOption.Strict, and I'm sure you'll start to get SPQueryThrottledException's
    as well on that list of 700000+ items.
    Thanks anyway though

  • How to get substring from string starting from the end of string

    Hi
    How to cut from string:
    $A=C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    this substring (name of VHD file): WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    This script should be universal so the best way to be cut all leters from the end of string $A till get the first mark \
    Thank you for help.
    Tomasz
    Kind Regards Tomasz

    PS > Split-Path 'C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781
    -A6DE-68497D4189B8.avhdx' -leaf
    WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    PS >
    That is what "Split-Path" is for:
    ¯\_(ツ)_/¯

  • How to get InputStream from String ?

    Hi !
    I want to get InputStream object from String.
    String str = "balabalabala";
    InputStream stream = getInputStream(str);
    How to realize getInputStream(str) function ?
    Thanks!

    The preferred method nowadays is to use Readers and Writers for String data - hence StringReader(String). If you're going to operate on the InputStream directly, then I'd modify your code to use the Reader calls and go that route.
    If, however, you need to pass the InputStream to some other piece of API that requires an InputStream instead of a Reader, then the ByteArrayInputStream is probably your best bet. StringBufferInputStream is deprecated because it doesn't work reliably in the face of many character encodings.
    Speaking of encodings - never call Strng.getBytes() - always use the getBytes(character-encoding) version, so you KNOW what encoding you're getting!
    Grant

  • New on POO : get items from purchase order

    Hi,
    i'm new in OO, i must implement the BADI IF_EX_ME_PROCESS_PO_CUST~CHECK. In this method i would like to get items of my current purchase order, how can i do that ?
    Thanks a lot.
    Cheers

    Hello
    Please note that if you have understood this BAdI then you have understood the basics of ALL BAdIs dealing with business objects that have a header and one or more items.
    Example: BAdI ME_PROCESS_REQ_CUST (purchase requisition)
    METHOD if_ex_me_process_REQ_cust~check.
    * define local data
      DATA:
        lt_items      TYPE mmpur_requisition_items,
    *    ls_item       LIKE LINE OF lt_items,  " alternatively
        ls_item       TYPE mmpur_requisition_item,
        ls_header     TYPE mereq_header.
    " Change data types of local variables (compared to if_ex_me_process_PO_cust~check)
    " but use the very same coding to retrieve the items.
    * (1) Get the order items
    *  CALL METHOD im_header->get_items
    *    receiving
    *      re_items = lt_items.
    * Short version:
      lt_items = im_header->get_items( ).
      LOOP AT lt_items INTO ls_item.
        ls_detail = ls_item-item->get_data( ).
    *   do something ...
      ENDLOOP.
    * (2) Get header data
    *  CALL METHOD im_header->get_data
    *    receiving
    *      re_data = ls_header.
    * Short version:
      ls_header = im_header->get_data( ).
    ENDMETHOD.
    Regards
      Uwe

  • How to get substring from string using index?

    hi,
    here i am having string ,
    i want the pullareddy from below line ,
    i know how to get from substring.
    but i want to get the above using "index",
    can any help how to do it?
    String str1="janapana,pullareddy, in malaysia";
    jpullareddy

    get the start index with indexAt("pullareddy")
    get the end index with adding the length of the word to the start
    get the char[] of str1 with toCharArray()
    make a new string with the chars from start to end index.

  • Can I get items from my iPad onto my Shuffle?

    I will be traveling with an iPad and my Shuffle (i.e., no computer with iTunes). I do have a MobileME account.
    Is there a way to get new items onto my Shuffle, either from the iPad or from MobileME? I use the Shuffle to listen to audio shows (podcasts, audiobooks, etc.) so once I have listened to something I want to erase it and load a new supply of items onto the Shuffle.
    Can this be done? How?

    In a word, No.
    Media content only comes in and goes out via iTunes I'm afraid.

  • Help on getting value from string

    Hello can someone please help me with my code?
    I would like to know how to get a value in a string as an integer type
    This is what I have so far
    String x = "12345";
    for(int f=0; f<5; f++){
    int c = stringDigits.charAt(f);     
    sum += c;                
    However the sum does not turn out to be 1+2+3+4+5 = 15 because the value of c will always turn out to be 48 more than it is supposed to be
    for example when f = 1 then c would = 49
    f = 2 then c would = 51
    Thank you very much for your help

    int i = Integer.parseInt(x);
    Will convert the String to an integer.The original poster was looking for a way to convert a single digit in a string to its numeric value, not to convert the whole string to an integer.
    I forgot to mention that this is contained in the
    java.text package, so you will need to
    import java.text.*;Integer is in the java.lang package, so no import is necessary.

  • Can we get Arraylist from String.Please check the code

    Hi all,
    I have just pasted my code over here.Can anyone of you find the solution for obtaining the Array list from the String.
    For Example :
    ArrayList al = new ArrayList();
    al.add(new byte[2]);
    al.add("2");
    String stringVar = "" + (ArrayList) al;
    Here I can convert the arraylist into string.But can we do he vice versa like obtaining the above arraylist from the string?If please advice me.
    URGENT!!!!

    cudIf you run the code you posted you will observe that the string form of the list does not contain all the information of the list: in particular the array elements are missing. It follows that the "vice versa" conversion you seek is simply not possible.
    A variation on this theme is the following:import java.util.ArrayList;
    public class ListEg {
        public static void main(String[] args) {
            ArrayList al = new ArrayList();
            al.add("foo");
            al.add("bar, baz");
            String stringVar = "" + (ArrayList) al;     
            System.out.println(stringVar);
    }If you think about the output you should be able to conclude that lists with different contents can easily have the same string form.
    Just something to chew on.

  • Get path from string in an column

    I have an data with text and url. I need to seprate the url only in the column and display in sql query
    Need to get data after Url: and the next immediate " " {blank space}
    my data is like below
    seach engine Url: www.bing.com this is the world famous search enging
    mail box Url: www.hotmail.com email is free
    microsoft webstie Url: http:\\microsoft.com the home page of microsoft.
    ShanmugaRaj

    Try the below:
    Create table Test_Shan(Textstring Varchar(1000))
    Insert into Test_Shan Values ('seach engine Url: www.bing.com this is the world famous search enging'),
    ('mail box Url: www.hotmail.com email is free'),
    ('microsoft webstie Url: http:\\microsoft.com the home page of microsoft.')
    Select substring(LTRIM(stuff(Textstring,1,CHARINDEX('Url:',Textstring)+4,' ')),0,charindex(' ',LTRIM(stuff(Textstring,1,CHARINDEX('Url: ',Textstring)+4,' ')),0))
    From Test_Shan

  • How to get items from catalog-help ASAP

    I have several completed scrapbook pages that I cannot find anywhere in computer. They are showing up in the
    Catalog -pictures are there and its not stating it is a missing file. When I try to
    open or copy them,it goes immediately to browse for missing file. How can it be missing if it is
    showing up just like I saved it. I ahve had a frustating 2 days. Yesterday I deleted all my blank
    quickpages that I had downloaded so now I have to do that over. I am afraid some of these that will not open from the catalog were
    accidentally saved in scrapbook materials files. PLease tell what I can do to get these out of the catalog-it is hours of work and I need to fiish this in a couple of days. Blessings,Kathy

    In the thumbnails of this images in the catalog, right click and go to Properties. When you click the folder icon at the bottom of the dialog box, you will be taken to the location where the scrapbook pages should be.
    Regards,
    Chhaya

Maybe you are looking for

  • What connector should I use??

    I have Imovie on my Ibook, but I don't know what type of connector should I use to download a personal clip. And how should I configure this device, somebody please let me know what I need to buy to download, edit and burn my movies. Thanks.

  • Very slow 3GS back up since 3.1 and iTunes 9

    Hi my first post on here, I was wondering if anyone is having the same hassle as I am, my 32GB 3GS has been connected for two hours now and its roughly a fifth of the way trying to back up despite a back up yesterday prior to 9 being installed, no la

  • Why are hyphens between numbers displayed as en dashes?

    Try this. Type a few numbers, then a hyphen, then another number. Now look what happens to the hyphen. It looks like an en dash, doesn't it? (If you don't know what an en dash is, type Option-hyphen.) The weird thing is that the character isn't repla

  • Lion Server Mobile accounts for Macbook users

    Hi All, I'm looking for a 'Best Practice' when setting up mobile accounts for Macbook users who just want to be able to use their machine away from the office. We DON'T want to sync anything, just create a mobile account on the Mac (a bit like a doma

  • Adobe reader will not print.

    When I click "print" or "file print" nothing happens. I have disabled "enable protected mode at startup". OS is Windows XP Home. [email address removed]