Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo
character selection in a string (Thursday, December 23, 2004)
 

Found the following interesting discussion in the Newsgroups:

character selection in a string
by:Anonymous

I have the following type of data sitting in a varaible:

Just Buttons+button

The text and lenght can change, however, no matter what the length is I would like to strip off the "+" sign and everything to the right of it and place it into another (or the same) variable. What is the easiest way to accomplish this?

Thank you,
John


 Reply:
by:Armin Zingler

 
Dim s As String

s = "Just Buttons+button"

s = s.Split("+"c)(0)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


 Reply:
by:Jay B. Harlow [MVP - Outlook]

 John,
In addition to Armin's suggestion:

Dim s As String

s = "Just Buttons+button"

s = s.SubString(0, s.IndexOf("+"c)

I suspect there are probably 2 or 3 other methods you could use ;-)

Hope this helps
Jay


 Reply:
by:Cor Ligthert

 HI Jay,

> I suspect there are probably 2 or 3 other methods you could use ;-)

It was for me a challenge and I can give of course a VB left function,
however the one you gave is the best in my opinion and therefore I will not
bring the OP in problems by giving him another one.

:-)

No need answering.

Cor



Posted by Xander Zelders



 
Previous Posts
    - Split function not working.....
    - Multi-Lingual application
    - HasChanges not being updated?
    - VB6 conversion of UDT to structure - ValueType?
    - Deployment question
    - Can a VB.NET 2003 project work with framework 1.0?...
    - .Net Assembly via VBS
    - Need to include original DLL with Interop?
    - Datagrid with a combobox
    - Passing variables from page to control

Archives
    - 10/03/2004 - 10/10/2004
    - 10/10/2004 - 10/17/2004
    - 10/17/2004 - 10/24/2004
    - 10/24/2004 - 10/31/2004
    - 10/31/2004 - 11/07/2004
    - 11/21/2004 - 11/28/2004
    - 11/28/2004 - 12/05/2004
    - 12/05/2004 - 12/12/2004
    - 12/12/2004 - 12/19/2004
    - 12/19/2004 - 12/26/2004
    - 12/26/2004 - 01/02/2005
    - 01/23/2005 - 01/30/2005
    - 01/01/2006 - 01/08/2006
    - 09/24/2006 - 10/01/2006


Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland