#if constants craziness!

  • Thread starter Thread starter Chris Nurse via .NET 247
  • Start date Start date
C

Chris Nurse via .NET 247

Option Compare Text

Module Module1

Sub Main()

#If MyString = "ABC" Then
MsgBox("You have been compiled!")
#End If

End Sub

End Module
----------------------

Create a new project , console app is ideal, and paste in the above code.

Create a conditional compilation(configuration properties->Build) variable...MyString="ABC"

The #if may or may not compile. On my machine as displayed above it compiles. But if I comment out the Option Compare line, then it will not compile.

According to the docs #if is not subject to Option Compare, specifically, it says all #if's assume Option Compare Text!

This is a PITA.

OK now for some really big craziness. Ensure the Option Compare is not commented out....

Use: CommonProperties->Build->Option Compare to change the value to Text, apply it try build, then change it to Binary, build and see what happens. The value here seems to interfere with the option compare specified at the top of the source!

If you can reproduce this problem then please respond. If not, then please don't worry. I am not mental and I can do that consistently just with a simple project and the source code above.

Regards,
 
I can reproduce it. Binary works and Text does not. It also seems to be
flaky when u change the option compare statement at the top, sometimes you
need to cut it, build replace and build again and it works.

There is probably a rational explaination to do with code page settings or
something depending on your regional locale

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

Chris Nurse via .NET 247 said:
Option Compare Text

Module Module1

Sub Main()

#If MyString = "ABC" Then
MsgBox("You have been compiled!")
#End If

End Sub

End Module
----------------------

Create a new project , console app is ideal, and paste in the above code.

Create a conditional compilation(configuration properties->Build) variable...MyString="ABC"

The #if may or may not compile. On my machine as displayed above it
compiles. But if I comment out the Option Compare line, then it will not
compile.
According to the docs #if is not subject to Option Compare, specifically,
it says all #if's assume Option Compare Text!
This is a PITA.

OK now for some really big craziness. Ensure the Option Compare is not commented out....

Use: CommonProperties->Build->Option Compare to change the value to Text,
apply it try build, then change it to Binary, build and see what happens.
The value here seems to interfere with the option compare specified at the
top of the source!
If you can reproduce this problem then please respond. If not, then please
don't worry. I am not mental and I can do that consistently just with a
simple project and the source code above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top