String: Substring, LastIndexOf : String « Data Types « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Data Types » StringScreenshots 
String: Substring, LastIndexOf
String: Substring, LastIndexOf
 
Imports System
Imports System.Collections
 
Public Class MainClass

    Shared Sub Main(ByVal args As String())
             Dim s1 As String = "One Two Three Four"

             Dim index As Integer

             index = s1.LastIndexOf(" ")

             Dim s2 As String = s1.Substring((index + 1))

             s1 = s1.Substring(0, index)

             index = s1.LastIndexOf(" ")

             Dim s3 As String = s1.Substring((index + 1))

             s1 = s1.Substring(0, index)

             index = s1.LastIndexOf(" ")

             Dim s4 As String = s1.Substring((index + 1))

             s1 = s1.Substring(0, index)

             index = s1.LastIndexOf(" ")

             Dim s5 As String = s1.Substring((index + 1))

             Console.WriteLine("s1: {0}", s1)
             Console.WriteLine("s2: {0}", s2)
             Console.WriteLine("s3: {0}", s3)
             Console.WriteLine("s4: {0}", s4)
             Console.WriteLine("s5: {0}", s5)
    End Sub

End Class

           
         
  
Related examples in the same category
1.String Object: =, Is and Mid
2.String InStrString InStr
3.String InsertString Insert
4.Combine Insert and IndexOfCombine Insert and IndexOf
5.Use the Mid function to replace within the stringUse the Mid function to replace within the string
6.Use String.Equals methodsUse String.Equals methods
7.Two ways to copy stringsTwo ways to copy strings
8.Compare String: case sensitive and not sensitiveCompare String: case sensitive and not sensitive
9.Two ways to concatenate stringsTwo ways to concatenate strings
10.Sub string with only one parameter
11.String PadLeftString PadLeft
12.String ConstructorString Constructor
13.String properties Length and Chars and method CopyTo of class StringString properties Length and Chars and method CopyTo of class String
14.Comparing stringsComparing strings
15.Demonstrating StartsWith and EndsWith methodsDemonstrating StartsWith and EndsWith methods
16.Using String searching methods: IndexOfUsing String searching methods: IndexOf
17.LastIndexOf to find a character in a stringLastIndexOf to find a character in a string
18.IndexOf to locate a substring in a stringIndexOf to locate a substring in a string
19.LastIndexOf to find a substring in a stringLastIndexOf to find a substring in a string
20.IndexOfAny to find first occurrence of character in arrayIndexOfAny to find first occurrence of character in array
21.LastIndexOfAny to find first occurrence of character in arrayLastIndexOfAny to find first occurrence of character in array
22.String Substring methodString Substring method
23.String class Concat methodString class Concat method
24.String ToLower and ToUpperString ToLower and ToUpper
25.String Trim methodString Trim method
26.String ToString methodString ToString method
27.String ToCharArray method String ToCharArray method
28.Concatenate the strings and display the resultsConcatenate the strings and display the results
29.The length of the stringThe length of the string
30.Display the first part of a string
31.String: set value and display
32.Concatenate the stringsConcatenate the strings
33.Display the length of the stringDisplay the length of the string
34.Get sub stringGet sub string
35.Replace the string occuranceReplace the string occurance
36.String compareString compare
37.String Replace DemoString Replace Demo
38.Concatenate String with Integer into one StringConcatenate String with Integer into one String
39.Compare two StringsCompare two Strings
40.Concatenate StringsConcatenate Strings
41.String CopyString Copy
42.String.Equals DemoString.Equals Demo
43.String IndexOf and InsertString IndexOf and Insert
44.String SplitString Split
45.Convert to Upper case and Lower CaseConvert to Upper case and Lower Case
46.Trim String spaceTrim String space
47.String ends withString ends with
48.String IndexOf and Insert at a positionString IndexOf and Insert at a position
49.Sample for String.LastIndexOfAny(Char[])
50.Split by ControlChars.Tab
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.