1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[C#]Stupid question about listbox

Discussion in 'C, C++, C#' started by Ampix0, Jan 12, 2012.

  1. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    Just need to know how I get the value of a certain line.
    I basically need to preform a loop (though im not using a loop, I am using timers)
    each time using data from the next line of the list box.
     
  2. Coron

    Coron Newbie

    Joined:
    Jan 13, 2012
    Messages:
    23
    Likes Received:
    0
    Code:
    Console.WriteLine(ListBox.Items[index].ToString());
     
  3. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    I actually have that now but I get this error
    "Error 1 Cannot convert method group 'ToString' to non-delegate type 'string'. Did you intend to invoke the method? C:\Users\Ampix0\documents\visual studio 2010\Projects\CommonThief Youtube view assult\CommonThief Youtube view assult\Form1.cs 170 29 CommonThief Youtube view assult
    "

    This is the actual line

    proxyItem = proxyBox.Items[proxyIndex].ToString;
    string = listbox .Items[integer ].ToString;
     
  4. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,059
    You forgot parentheses () at the end of ToString.
     
  5. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    Yup how funny is that. ok. problem two now lol

    here's the imgur link, I cant post actual links yet

    i.imgur /8E8bW.jpg
     
  6. 45415

    45415 Junior Member

    Joined:
    Feb 5, 2009
    Messages:
    194
    Likes Received:
    92
    Substring method must be zero based. Try changing proxyItem.Length to proxyItem.Length - 1. That should be the last character if you start counting from 0. Correct me if I'm wrong.
     
  7. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    I had actually tried that too before, should have left it in the picture..

    however.

    the word "testing" has a length of 5. and -1 would still miss the last letter i believe.

    same error though
     
  8. 45415

    45415 Junior Member

    Joined:
    Feb 5, 2009
    Messages:
    194
    Likes Received:
    92
    Looked at the picture again. So you are trying to get the port number from a string in format ip : port? Then the start index should be (delimiter + 1) as in your picture and the length should be (proxyItem.Length - (delimiter + 1)). If that doesn't work, then it's probably time to go to sleep. 4:30 AM here.
     
    Last edited: Jan 14, 2012
  9. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    Omg this is crazy. look at this BS
    i.imgur/X5FlJ
     
  10. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    AH HA! we had it all wrong! it isn't from point A to Point b
    it is from Point A, and a length. so .length was far too long. overloading it just as (delimeter +1) ported perfectly.
     
  11. hatemachine

    hatemachine Regular Member

    Joined:
    Jan 14, 2011
    Messages:
    271
    Likes Received:
    1,138
    Bloody hell. Use a Dictionary<> to store your proxies, not a listbox. The listbox is supposed to display them, not more; not less.
     
  12. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    well now it does both and saves ram.