jimbo2k Posted April 3, 2004 Posted April 3, 2004 Any Help would be greatly appreciated I need a way to find a number after either one space, or two. Ex: Number1: 555 <---one space Ex2: Number1: 666 <---two spaces I know how I could do each one independantly, but I'd need it all in one code. This code will find the number 555 in the first scenerio (one space) but wont work for the second scenerio (with two spaces): Position1 = InStr(FirstString, "Number1: ") 'finds start position by finding "Number1: " EndPosition = InStr(Position1 + 9, FirstString, " ") 'finds end position by finding the space after the number: (use +9 because the word "Number1: " is 9 characters) Label1.Text = Mid(FirstString, Position1 + 9, EndPosition - Position1 - 9) 'inbetween start and end is the number PS: how do I format using .net? Quote
Leaders Iceplug Posted April 3, 2004 Leaders Posted April 3, 2004 Try using Replace: FirstString = FirstString.Replace(" ", " ") Also, consider using .NET System methods instead of VB compatibility methods. InStr( S, other args ) is now S.IndexOf( other args ) Mid(S, other args ) is now S.SubString( other args), where the string is now 0-based instead of 1-based. To format in .NET, use .ToString() But, Mid and .SubString both return strings... it would be redundant to convert the string to a string. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
jimbo2k Posted April 3, 2004 Author Posted April 3, 2004 Quote Try using Replace: FirstString = FirstString.Replace(" ", " ") Also, consider using .NET System methods instead of VB compatibility methods. InStr( S, other args ) is now S.IndexOf( other args ) Mid(S, other args ) is now S.SubString( other args), where the string is now 0-based instead of 1-based. To format in .NET, use .ToString() But, Mid and .SubString both return strings... it would be redundant to convert the string to a string. :) Thanks, Ill have a look into what you suggested. As for formatting in .NEt i meant for the forum, instead of VB tags what are the VB.net tags? :p Thanks again! Quote
Leaders Iceplug Posted April 3, 2004 Leaders Posted April 3, 2004 The VB.NET tags are ;). Similarly, C# tags are [code=csharp]. I'm working on a syntax highlighter for myself in .NET :). Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
jimbo2k Posted April 3, 2004 Author Posted April 3, 2004 Then why dont the keywords and comments appear in their proper color? Quote
Leaders Iceplug Posted April 4, 2004 Leaders Posted April 4, 2004 Because they aren't working yet. :o Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
jimbo2k Posted April 4, 2004 Author Posted April 4, 2004 Ahh, that explains it. I thought I've seen .Net formatting already, but maybe that was in the sister forum. :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.