Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Dave \"Crash\" Dummy" Newsgroups: microsoft.public.scripting.vbscript Subject: Re: Weird bug Date: Mon, 16 Nov 2015 15:28:09 -0500 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 16 Nov 2015 20:25:51 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="847cb9ac544c0d3986237452b863d7e6"; logging-data="4424"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qaJ24yoKyi2y7Gtku5LxByLCoMhxleh4=" User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) In-Reply-To: Cancel-Lock: sha1:YgCSmWRvGbEDZFmS3HdwfyiUoWA= Xref: csiph.com microsoft.public.scripting.vbscript:11183 Mayayana wrote: > I just wasted hours before discovering this: > > x = -18 > > x = x + 9: If x > 10 Then x = 10: If x < 0 Then x = 0 > > MsgBox x > > ' Returns -9, but, this works: > > x = -18 > > x = x + 9: If x < 0 Then x = 0 > > MsgBox x > > Why? Is only one colon allowed? I've never noticed that > > problem before. It works fine in VB6. Operations after "Then" on the line are only carried out if the conditional statement is true. In your first example, the condition is false and everything else on the line is ignored. In the second example, the condition is true and the subsequent operations are carried out. AFAIK the only limit to the number of operations that can be chained with colons is the character length of the line. -- Crash "I am not young enough to know everything." ~ Oscar Wilde ~