vb.net, looking for a function

Discussion in 'Software' started by unclematty, Apr 24, 2004.

  1. unclematty

    unclematty Private First Class

    vb.net, looking for a function that will return all a set number of characters from a given part of a string. for instance...

    lets say i have a string. that string is "string@home". i want to return all of the characters that follow '@'.

    i would the call would look something like this...
    Code:
      functionname(string, [i]string i am looking for[/i], [i]number of chars following[/i]) 
     
  2. jawpaul

    jawpaul Private E-2

    lemme double check stuff this is fairly simple for me
     
    Last edited: Apr 25, 2004
  3. jawpaul

    jawpaul Private E-2

    Alright you will be using two different methods(I think thats what the are called) of your string.


    First is the IndexOf
    This searches the string it is called from for the given character. It returns the index of that charachter in the string.

    Example:
    Code:
    dim strString as string
    dim intIndex as integer
     
    strString [size=2]= "John Lane"
    [/size]intIndex = strString.IndexOf("h")
      
    This sets intIndex to 3 which is the index of the letter "h".

    Now to get a part of a string we use the SubString Method.
    This can take two arguments: The Index of the start of the substring, and the Length of the substring (only the Index is required).

    Example:(append to above code)
    Code:
     
    dim strSub as string
    strSub = strString.SubString(intIndex)
     
    This should assign "n Lane" to strSub

    Play around with it and use the tooltip that pops up with the intellisense for help.
     
  4. unclematty

    unclematty Private First Class

    jawpaul,

    you're a life saver. this is ALMOST EXACTLY what i am looking for. Your example does everything i need, with one exception.

    I need the substring method to stop at a set number of characters after the index.

    Thanks
     
  5. jawpaul

    jawpaul Private E-2

    Easy, reread my above post and it says it

    But so you don't have to.

    The substring method can take two arguments the index, and the length of the substring.

    strSub = strString.SubString(intIndex, intLength)

    You know the tooltip that pops up when you are typing inside of the paranthesis read these for info on the arguments of the method. You can use the up and down arrow keys to scroll trhough the different arguments the method can take.

    The SubString method, has two (Index), and (Index, Length).
    Whatever argument you are typing it displays the information on what it is on the bottom line of the tooltip, it also says what type of variable it needs to be (string, charachter, interger, etc.)

    Very helpfull.

    Also if You hover the mouse pointer over the item's that pop up in the intellisense after you use the Dot operator it generally says what each method does.
     
  6. unclematty

    unclematty Private First Class

    Holy Crapola! Huge Help. The thing I hadnt realized before was the fact that the functions had 2 sets of arguments.

    Thats awsome. All hail to jawpaul. Unfortunately im not finished with this little project and i can almost garuntee some more questions.

    Hope you up to it!
     
  7. jawpaul

    jawpaul Private E-2

    Well most functions have even more than that, intellisense has really helped me out at times.

    I am glad I could help you some man.

    It's good to be able to put some of these two semesters of VB.Net expeirence to work. Man I loved these classes.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds