Consulting

Results 1 to 2 of 2

Thread: Solved: Test Multiple Variable for Same Result

  1. #1
    VBAX Regular
    Joined
    Jun 2008
    Posts
    72
    Location

    Solved: Test Multiple Variable for Same Result

    What's the best way to test multiple variable to see if they have the same value?

    Example:
    [vba]
    Dim Var1 as Long
    Dim Var2 as Long
    Dim Var3 as Long
    Dim Var4 as Long

    If all 4 Variables are the same Then
    Goto Here
    Else
    Goto There
    End if
    [/vba]

    What's the best way to write the line in Red? Thanks.

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    There are many ways to test this. One way is like this:
    [VBA]Sub Test()
    Dim a As Integer, x As Integer, y As Integer, b As Integer
    a = 1
    b = 1
    x = 1
    y = 1
    If (a = b And b = x And x = y) Then
    MsgBox "Match!"
    End If
    End Sub[/VBA]
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •