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
Printable View
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
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.
i would like to compare the 2 strings.
newcar = red
car can't =0"
NOt sure what you want but to compare two strings:
Going back to your code: what does it say??? (especially the Car Can't = "0" part makes me confused)Code:Dim strOne As String
Dim strTwo As String
If strOne = strTwo Then
MsgBox "Strings Are Identical"
Else
MsgBox "Strings Are Different"
End if
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"
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.
In this case, your if statement would beCode:newcar car Result
"red" "1" valid
"red" "0" invalid
"blue" "1" valid
"blue" "0" valid
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..Code:If (newcar = "red") And (car <> "0") then Result = true
Regards
Paul Lewis