|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to find the position of the first dash in a stringlets' say I have a value ABCD - 123
How can I return the position of the dash ? > lets' say I have a value ABCD - 123 Do you mean that you have a string containing "ABCD - 123"? If so, use > > How can I return the position of the dash ? Instr(). AMercer wrote:
> > lets' say I have a value ABCD - 123 The "proper" .NET way would be to use the IndexOf method.> > > > How can I return the position of the dash ? > > Do you mean that you have a string containing "ABCD - 123"? If so, use > Instr(). za***@construction-imaging.com wrote:
> AMercer wrote: But surely, then you should check that the string isn't Nothing first or you >>> lets' say I have a value ABCD - 123 >>> >>> How can I return the position of the dash ? >> >> Do you mean that you have a string containing "ABCD - 123"? If so, >> use Instr(). > > The "proper" .NET way would be to use the IndexOf method. could get an ArgumentNullException . Why do you consider the VB.NET method as not "proper" when programming in VB.NET? Would you exclusively use "String.Concat" rather than "&" ?. Andrew x = instr("ABCD - 123", "-")
Show quoteHide quote "Rob" <rwch***@comcast.net> wrote in message news:cOCdnXEKArCAIIbYnZ2dnUVZ_rKdnZ2d@comcast.com... > lets' say I have a value ABCD - 123 > > How can I return the position of the dash ? > Dim s As String = "ABCD - 123"
s.IndexOf("-").ToString() Show quoteHide quote "Rob" <rwch***@comcast.net> wrote in message news:cOCdnXEKArCAIIbYnZ2dnUVZ_rKdnZ2d@comcast.com... > lets' say I have a value ABCD - 123 > > How can I return the position of the dash ? > "Rob" <rwch***@comcast.net> schrieb: 'Strings.InStr', 'String.IndexOf'.> lets' say I have a value ABCD - 123 > > How can I return the position of the dash ? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> dim i as integer = YourString.IndexOf("-")
if i < 0 the pattern does not exist in the string, otherwise, "i" has the offset of the start of the string. Rob wrote: Show quoteHide quote > lets' say I have a value ABCD - 123 > > How can I return the position of the dash ? Rob wrote:
> lets' say I have a value ABCD - 123 Dim s As String = "ABCD - 123"> > How can I return the position of the dash ? Console.WriteLine (s.IndexOf ("-")) or Dim s As String = "ABCD - 123" Console.WriteLine (InStr (s, "-")) -- Tom Shelton
Are optional parameters really an advisable thing to use ?
Handle Worked - can someone please double check Multiple child forms - updating the right one keypressed Export array from vb.net to excel File converting/sending help Looking for a real working transparent picturebox Ftp Client Help (newbie -vb2005) going back to begin of file with StreamReader printdialog problem |
|||||||||||||||||||||||