Consulting

Results 1 to 6 of 6

Thread: Checking to see if a variable is = to another variable

  1. #1
    VBAX Contributor Daxton A.'s Avatar
    Joined
    Jun 2004
    Location
    Biloxi, Mississippi
    Posts
    143
    Location

    Checking to see if a variable is = to another variable

    Does anyone know how to do this?


    Let's say that I have this loop and I want it to test a variable and see if it is = to a value but I don't want to make that variable = to that value. I remember how to do it in C++. All ya have to do is use another =, but I can't remember how it was done in visual basic.

    Example in C++:
    intTest == 12

  2. #2
    VBAX Regular
    Joined
    Jun 2004
    Location
    Cordova, Alaska
    Posts
    10
    Location
    Hi,

    Not sure if I'm understanding completely, but you might try
    If intTest = 12 Then
    (Or if this 12 is going to be entered as text)
    If intTest = "12" Then
    Either way you'll need to include an End If somewhere before the end of your routine. (Just where can be important depending on the rest of your code...)

    Is this what you're after?
    Dan
    Last edited by Aussiebear; 04-29-2023 at 10:15 PM. Reason: Adjusted the Code tags

  3. #3
    VBAX Contributor Daxton A.'s Avatar
    Joined
    Jun 2004
    Location
    Biloxi, Mississippi
    Posts
    143
    Location

    Cool

    What if you want to test a variable though, then what is used.

    EX: variable = variable

  4. #4
    VBAX Regular
    Joined
    Jun 2004
    Location
    Cordova, Alaska
    Posts
    10
    Location
    You would just reference them both by name. Such as

    If Variable1 = Variable2 Then
    Last edited by Aussiebear; 04-29-2023 at 10:13 PM. Reason: Adjusted the code tags

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    If I understood you..

    If inTest = inTest2 Then
    Just substitute the variables for what you want. Is this hitting close? Not sure if it's what you're looking for. If still not, how about posting the whole, or a portion, of your code.
    Last edited by Aussiebear; 04-29-2023 at 10:12 PM. Reason: Adjusted the code tags

  6. #6
    VBAX Contributor Daxton A.'s Avatar
    Joined
    Jun 2004
    Location
    Biloxi, Mississippi
    Posts
    143
    Location

    You hit it right on the money

    Thank You both for the help

Posting Permissions

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