How to Test Equivalency in Visual Basic

104 14
    • 1). Open the Visual Basic 6.0 program and create a new project to demonstrate a simple way to test equivalency. Choose "Standard EXE" from list of displayed templates.

    • 2). Add a "CommandButton" from the Toolbox in the left-hand panel to the form in the center screen by double-clicking on the small rectangle below the capital "A." Add a "Label" to the form by double-clicking on the capital "A" icon in the Toolbox.

    • 3). Click on the label you added to display its properties in the right-hand panel. Locate the "Caption" property and double-click it to highlight the current setting. Clear this with the "Delete" key. Change the "Name" property to change the caption of the CommandButton in the same way, but make this one read "Test Equivalency."

    • 4). Click on "View," and then "Code" in the Visual Basic menu across the top of the screen. In the Code window, enter the following lines of code:

      Private Sub Command1_Click()

      Dim firstvariable, secondvariable As Variant

      Dim Result As String

      firstvariable = InputBox("Enter first variable")

      secondvariable = InputBox("Enter second variable")

      If firstvariable = secondvariable Then

      MsgBox ("The two variables are equivalent")

      Else: MsgBox ("The two variables are not equivalent")

      End If

      End Sub

    • 5). Press "F5" to run the program. At the prompts, enter two variables, either numbers or words. The application will test whether the items are equivalent and display the result.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.