Results 1 to 4 of 4

Thread: String Comparision in vb.net

  1. #1
    Join Date
    Feb 2009
    Posts
    53

    String Comparision in vb.net

    I want to use the string comparison in vb.net. I want to compare two strings. I have a sample data base for a project work. But I am not clear about the issue. I need some reference and also if possible some sample codes which I can view in that. Some simple examples and a general idea about the string comparison would be a great help. Thanks in advance.

  2. #2
    Join Date
    Feb 2009
    Posts
    53

    Re: String Comparision in vb.net

    Normally working with string is very important function in most of the applicatons. VB.NET String comparison method is very simple and handy. You can use it anytime you need to compare two strings variables. The parameter for this is "String". Compare method is the first thing you want to compare with the string to be compared. Here the boolean value will determine that this should be considered in comparison. If you want to ignore case then specify True. For the check to include the case then specify False.
    Code:
    Private Sub CompareStrings()
     
          Dim str1, str2 As String
          str1 = "go4expert"
          str2 = "GO4expert"
     
          MessageBox.Show(String.Compare(str1, str2, False))
          MessageBox.Show(String.Compare(str1, str2, True))
     
      End Sub

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: String Comparision in vb.net

    The classes are provided by the .net framework and these classes are very common. The compare method is use to compare two strings and returns a integer value. The return value can either be less than zero or greater that zero or equal to zero. The value less than zero means that the first string is less than a second, the value with zero indicates that both strings are equal and more than zero shows that first string is greater than zero. See the below code used to compare the strings :
    Code:
    Dim str1 As String = "Max"
    Dim str2 As String = "joy"
    Dim res As Int16 = String.Compare(str1, str2)
    Console.WriteLine("First result:" + res.ToString())
    str2 = "ttt"
    res = String.Compare(str1, str2)
    Console.WriteLine("Second result:" + res.ToString())
    str1 = "ttt"
    res = String.Compare(str1, str2)
    Console.WriteLine("Third result:" + res.ToString())

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: String Comparision in vb.net

    String compare method is a quick method to perform comparison between the strings. It is gives you an exact result in values. The parameter used here is string. Here you will have to provide the syntax of value which is going to be compare and the value by which the first is compared. The result will be in the form of a integer value.

Similar Threads

  1. CSS in comparision with HTML
    By Visala28 in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 11:06 AM
  2. How to Manipulate String using PHP String Functions
    By ComPaCt in forum Software Development
    Replies: 3
    Last Post: 21-09-2009, 09:07 AM
  3. Need some information on Alienware Comparision
    By ZeDaX in forum Hardware Peripherals
    Replies: 3
    Last Post: 18-09-2009, 11:33 PM
  4. How to use Excel Pairwise comparision
    By In2TheBlues in forum Windows Software
    Replies: 3
    Last Post: 25-06-2009, 01:08 PM
  5. Comparision between Intel 2.3 Ghz and 2.5 Ghz
    By BUCK in forum Hardware Peripherals
    Replies: 3
    Last Post: 19-06-2009, 11:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,878,051.21301 seconds with 16 queries