Results 1 to 6 of 6

Thread: comparison problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    28

    Question

    i would like to compare two statements

    sub car()
    if newcar = "red" Then
    Car can't = "0"
    end if
    end sub



    how would I write this

  2. #2
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307
    Man
    I am sure there are some more ppl who didnt understand what you are trying to compare.
    do u wanna compare Strings ? what do u mean to compare "Statements" ?!
    explain yourself please.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    28
    i would like to compare the 2 strings.
    newcar = red
    car can't =0"


  4. #4
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    NOt sure what you want but to compare two strings:
    Code:
    Dim strOne As String
    Dim strTwo As String
    
    If strOne = strTwo Then
        MsgBox "Strings Are Identical"
    Else
        MsgBox "Strings Are Different"
    End if
    Going back to your code: what does it say??? (especially the Car Can't = "0" part makes me confused)

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    if your variables are strings and the strings are
    Sring1 = newcar
    String2 = car
    and it looks like you want to say that if
    newcar is red then it cannot be 0
    if that is the case this is the statement.

    if newcar = "red" then car <> "0"
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    Heres a help..

    Hi Raven123,

    You look like you need a help with a bit of analysis rather than specific statements (although maybe that too)

    To help you to analyse your problem and to help you to express your question more fully, try using a technique like the following one.

    Draw up a number of columns on a piece of paper with headers on the names of the variables you want to use

    Now, draw up a final column and call it "Result" or something like that which means something to you.

    Now, fill in the columns as many times as needed until you think you have accounted for every type of combination of variables.

    Now think about the results in each case and write what you want the result to be.

    I will do this as an example and see if you get a similar result.

    Code:
    newcar     car     Result
    "red"      "1"     valid
    "red"      "0"     invalid
    "blue"     "1"     valid
    "blue"     "0"     valid
    In this case, your if statement would be

    Code:
    If (newcar = "red") And (car <> "0") then Result = true
    Unfortunately there was not enough information to fully appreciate what you intend the Sub to do, but looking at the problem on paper like I hopefully have demonstrated might help you to get an exact answer to your question..


    Regards
    Paul Lewis

Posting Permissions

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



Click Here to Expand Forum to Full Width