Comparing Strings in Visual Basic .Net

Download
Download is available until [expire_date]
  • Version
  • Download 54
  • File Size 63.79 KB
  • File Count 1
  • Create Date April 29, 2016
  • Last Updated April 29, 2016

Comparing Strings in Visual Basic .Net

Comparing Strings in Visual Basic .Net

This is sample program in vb.net that compares the value of two strings. The user will enter value of string 1 and string 2 then selects an operator to test if it is equal or not. A message will be displayed if string 1 matches string 2 or if it did not.

Open the project solution (.sln) in visual studio 2010/2012 or open directly the project file (.vbproj)
Source code:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.Text = "= (Equality)" Then
            If TextBox1.Text = TextBox2.Text Then
                MessageBox.Show("string 1 is equal to string 2")
            End If
        ElseIf ComboBox1.Text = "<> (Inequality)" Then
            If TextBox1.Text <> TextBox2.Text Then
                MessageBox.Show("string 1 is not equal to string 2")
            End If     
        End If
    End Sub
End Class
, , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.