Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 02-06-2009
Member
 
Join Date: Nov 2008
Posts: 1,022
LastIndexOf in VB.NET

Does anyone know how to use LastIndexOf in VB.NET? I am creating a project in VB.NET and I don't know how to use LastIndexOf in this. I just need a small idea alongwith syntax for this in VB.NET. I know how to use it in JAVA but not in VB.NET. Can you help me?
Reply With Quote
  #2  
Old 02-06-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: LastIndexOf in VB.NET

String.LastIndexOf Method

Reports the index position of the last occurrence of a specified Unicode character or String within this instance.
  • LastIndexOf(Char): Reports the index position of the last occurrence of a specified Unicode character within this instance.
  • LastIndexOf(String): Reports the index position of the last occurrence of a specified String within this instance.
  • LastIndexOf(Char, Int32): Reports the index position of the last occurrence of a specified Unicode character within this instance. The search starts at a specified character position.
  • LastIndexOf(String, Int32): Reports the index position of the last occurrence of a specified String within this instance. The search starts at a specified character position.
  • LastIndexOf(String, StringComparison): Reports the index of the last occurrence of a specified string within the current String object. A parameter specifies the type of search to use for the specified string.
  • LastIndexOf(Char, Int32, Int32): Reports the index position of the last occurrence of the specified Unicode character in a substring within this instance. The search starts at a specified character position and examines a specified number of character positions.
  • LastIndexOf(String, Int32, Int32): Reports the index position of the last occurrence of a specified String within this instance. The search starts at a specified character position and examines a specified number of character positions.
  • LastIndexOf(String, Int32, StringComparison): Reports the index of the last occurrence of a specified string within the current String object. Parameters specify the starting search position in the current string, and type of search to use for the specified string.
  • LastIndexOf(String, Int32, Int32, StringComparison): Reports the index position of the last occurrence of a specified String object within this instance. Parameters specify the starting search position in the current string, the number of characters in the current string to search, and the type of search to use for the specified string.
Reply With Quote
  #3  
Old 02-06-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: LastIndexOf in VB.NET

String: LastIndexOf in VB.NET

Sample code:

Code:
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
Output:
Quote:
s1: One
s2: Four
s3: Three
s4: Two
s5: One
Reply With Quote
  #4  
Old 29-06-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: LastIndexOf in VB.NET

LastIndexOf belongs to "System.String" instance. It finds the last position (or IndexOf) a character or string object in a string. It is similar to the RIGHT function in Visual Basic 6. It gives you three types of values in VB.NET. If this function finds the searched character in the given string then it shows the actual position of that character; if it is not found then it returns -1 (FALSE) and if it is empty then it returns 0 (EMPTY).
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search



All times are GMT +5.5. The time now is 03:07 AM.