Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is True ??
I run this
Sub macro() Dim t As Integer Dim t2 As Integer t = 1 t2 = (t = 1) * 7 MsgBox (t2) End Sub and it says -7, not 7 Why? -- jake |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is True ??
i'd guess and say the () change it to a negative number but i don't know why
you;re doing that anyway t2 = (t * 7) is all you need -- Gary "Jakobshavn Isbrae" wrote in message ... I run this Sub macro() Dim t As Integer Dim t2 As Integer t = 1 t2 = (t = 1) * 7 MsgBox (t2) End Sub and it says -7, not 7 Why? -- jake |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is True ??
Jakobshavn Isbrae wrote:
I run this Sub macro() Dim t As Integer Dim t2 As Integer t = 1 t2 = (t = 1) * 7 MsgBox (t2) End Sub and it says -7, not 7 Why? Because in VBA TRUE = -1, while in Excel TRUE = 1, so when you write t=1 its TRUE and than you multiply TRUE (i.e. -1) times 7... -- Hope I helped you. Thanks in advance for your feedback. Ciao Franz Verga from Italy |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is True ??
Because you cannot assign a value to multiple variables in a oneliner like in C++. You already gave t a value of 1. Why do you do that again in t2 = (t=1) * 7 This one gives 7. Sub macro() Dim t As Integer Dim t2 As Integer t = 1 t2 = t * 7 MsgBox (t2) End Sub "Jakobshavn Isbrae" schreef in bericht ... I run this Sub macro() Dim t As Integer Dim t2 As Integer t = 1 t2 = (t = 1) * 7 MsgBox (t2) End Sub and it says -7, not 7 Why? -- jake |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is True ??
On Thu, 31 Aug 2006 17:13:01 -0700, Jakobshavn Isbrae
wrote: I run this Sub macro() Dim t As Integer Dim t2 As Integer t = 1 t2 = (t = 1) * 7 MsgBox (t2) End Sub and it says -7, not 7 Why? From VBA HELP: "When Boolean values are converted to other data types, False becomes 0 and True becomes -1." So your formula reduces to: t2 = -1 * 7 t2 = -7 --ron |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
What is True ??
Thank you Franz.
I did not know the booleans had different number values in VBA. Thanks again -- jake "Franz Verga" wrote: Jakobshavn Isbrae wrote: I run this Sub macro() Dim t As Integer Dim t2 As Integer t = 1 t2 = (t = 1) * 7 MsgBox (t2) End Sub and it says -7, not 7 Why? Because in VBA TRUE = -1, while in Excel TRUE = 1, so when you write t=1 its TRUE and than you multiply TRUE (i.e. -1) times 7... -- Hope I helped you. Thanks in advance for your feedback. Ciao Franz Verga from Italy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
if any of 3 conditions is true, then answer is true | Excel Worksheet Functions | |||
Search for 2 true arguments and return true or false | Excel Discussion (Misc queries) | |||
Function to return True/False if all are validated as True by ISNU | Excel Worksheet Functions | |||
How do I stop Excel from changing the word true to TRUE? | Excel Discussion (Misc queries) | |||
Reverse false and combine with true true value | Excel Worksheet Functions |