From: Claire on
Hello,
I have just came across this problem:
This line of code:
If rlineGetDevCaps(l) = True And LineID(l) =
Val(Mid(sSelectLines, i + 4, k - i)) Then
(some code here)
Else
MsgBox "Lines have changed since the last use.",
vbExclamation, "Line Error"
End If

rlineGetDevCaps(l) is the function and LineID(l) is one of parameters
returned by that function

This line of code works properly in development stage but when compiled it
does not.
Despite both conditions met the msgbox is displayed.
Why that works in ide but not when compiled?

I corrected the problem by splitting the conditions:
If rlineGetDevCaps(l) = True Then
If LineID(l) = Val(Mid(sSelectLines, i + 4, k - i))
Then
(some code here)
Else
MsgBox "Lines have changed since the last use.",
vbExclamation, "Line Error"
End If
End If

but I wonder if that is a common problem?
Your input appreciated,
Claire


From: duke on
On Jun 29, 5:54 pm, "Claire" <replyto(a)fra> wrote:
> Hello,
>          I have just came across this problem:
> This line of code:
>                     If rlineGetDevCaps(l) = True And LineID(l) =
> Val(Mid(sSelectLines, i + 4, k - i)) Then
>                         (some code here)
>                     Else
>                         MsgBox "Lines have changed since the last use.",
> vbExclamation, "Line Error"
>                     End If
>
> rlineGetDevCaps(l) is the function and LineID(l) is one of parameters
> returned by that function
>
> This line of code works properly in development stage but when compiled it
> does not.
> Despite both conditions met the msgbox is displayed.
> Why that works in ide but not when compiled?
>
> I corrected the problem by splitting the conditions:
>                     If rlineGetDevCaps(l) = True Then
>                         If LineID(l) = Val(Mid(sSelectLines, i + 4, k - i))
> Then
>                         (some code here)
>                         Else
>                             MsgBox "Lines have changed since the last use.",
> vbExclamation, "Line Error"
>                         End If
>                     End If
>
> but I wonder if that is a common problem?
> Your input appreciated,
> Claire

Without all the values associated with your code it is not possible to
determine why it works compiled but not in the IDE but I suspect that
something is different, however, your correction to the problem is
very good.

Would you not agree that your correction is much more readable and is
more conducive to inserting the "else" possibilities when required?

Frankly I avoid those compound conditions involving "and" , "or" at
all costs simply for their confusing nature.

Duke
From: Henning on

"Claire" <replyto(a)fra> skrev i meddelandet
news:Ofp6qZ%23FLHA.1996(a)TK2MSFTNGP06.phx.gbl...
> Hello,
> I have just came across this problem:
> This line of code:
> If rlineGetDevCaps(l) = True And LineID(l) =
> Val(Mid(sSelectLines, i + 4, k - i)) Then
> (some code here)
> Else
> MsgBox "Lines have changed since the last use.",
> vbExclamation, "Line Error"
> End If
>
> rlineGetDevCaps(l) is the function and LineID(l) is one of parameters
> returned by that function
>
> This line of code works properly in development stage but when compiled it
> does not.
> Despite both conditions met the msgbox is displayed.
> Why that works in ide but not when compiled?
>
> I corrected the problem by splitting the conditions:
> If rlineGetDevCaps(l) = True Then
> If LineID(l) = Val(Mid(sSelectLines, i + 4, k - i))
> Then
> (some code here)
> Else
> MsgBox "Lines have changed since the last
> use.", vbExclamation, "Line Error"
> End If
> End If
>
> but I wonder if that is a common problem?
> Your input appreciated,
> Claire
>

The compiler might see it different than the ide. I've used squarebrackets
to visualize.
1.
If [rlineGetDevCaps(l) = True And LineID(l)] =
Val(Mid(sSelectLines, i + 4, k - i)) Then

2.
If [rlineGetDevCaps(l) = True] And [LineID(l) =
Val(Mid(sSelectLines, i + 4, k - i))] Then

Does added parens make any difference?
If (rlineGetDevCaps(l) = True) And (LineID(l) =
Val(Mid(sSelectLines, i + 4, k - i))) Then

I agree with Duke about readability. ;)

/Henning


From: ralph on
On Tue, 29 Jun 2010 19:54:16 -0400, "Claire" <replyto(a)fra> wrote:

>Hello,
> I have just came across this problem:
>This line of code:
> If rlineGetDevCaps(l) = True And LineID(l) =
>Val(Mid(sSelectLines, i + 4, k - i)) Then
> (some code here)
> Else
> MsgBox "Lines have changed since the last use.",
>vbExclamation, "Line Error"
> End If
>
>rlineGetDevCaps(l) is the function and LineID(l) is one of parameters
>returned by that function
>
>This line of code works properly in development stage but when compiled it
>does not.
>Despite both conditions met the msgbox is displayed.
>Why that works in ide but not when compiled?
>
>I corrected the problem by splitting the conditions:
> If rlineGetDevCaps(l) = True Then
> If LineID(l) = Val(Mid(sSelectLines, i + 4, k - i))
>Then
> (some code here)
> Else
> MsgBox "Lines have changed since the last use.",
>vbExclamation, "Line Error"
> End If
> End If
>
>but I wonder if that is a common problem?
>Your input appreciated,
>Claire
>

Curious. What happens if you compile to pcode?
From: Claire on
Ralph, compiling to pcode works!
What is a difference between pcode and native code (default) compilation?
Which one should I use?
Claire

"ralph" <nt_consulting64(a)yahoo.net> wrote in message
news:ldal26t2ttk2jfuhsi1gjba5t3oepd87jr(a)4ax.com...
> On Tue, 29 Jun 2010 19:54:16 -0400, "Claire" <replyto(a)fra> wrote:
>
>>Hello,
>> I have just came across this problem:
>>This line of code:
>> If rlineGetDevCaps(l) = True And LineID(l) =
>>Val(Mid(sSelectLines, i + 4, k - i)) Then
>> (some code here)
>> Else
>> MsgBox "Lines have changed since the last use.",
>>vbExclamation, "Line Error"
>> End If
>>
>>rlineGetDevCaps(l) is the function and LineID(l) is one of parameters
>>returned by that function
>>
>>This line of code works properly in development stage but when compiled it
>>does not.
>>Despite both conditions met the msgbox is displayed.
>>Why that works in ide but not when compiled?
>>
>>I corrected the problem by splitting the conditions:
>> If rlineGetDevCaps(l) = True Then
>> If LineID(l) = Val(Mid(sSelectLines, i + 4, k -
>> i))
>>Then
>> (some code here)
>> Else
>> MsgBox "Lines have changed since the last
>> use.",
>>vbExclamation, "Line Error"
>> End If
>> End If
>>
>>but I wonder if that is a common problem?
>>Your input appreciated,
>>Claire
>>
>
> Curious. What happens if you compile to pcode?


 |  Next  |  Last
Pages: 1 2 3 4 5 6 7
Prev: Activate the first input element
Next: One Shot Timers