Solved

Visual Studio Option Compare

Posted on 2013-06-07
5
474 Views
Last Modified: 2013-06-07
I apologize in advance for any nomencalture or verbiage that makes no sense.

From what I understand, in Visual Studio 2010 default settings...

In VB if I do this

If "LBrister" = "lbrister" Then
   Return True
Else
   Return False
End If

I should get False?


And if I change my settings in Tools Options (Screen Print) for Options Compare
From Binary
To Text

The above VB should return True?

My real question...
On application build...will that still hold true...
In other words, does the Option Compare go with the build?

sc
0
Comment
Question by:lrbrister
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 39230440
I don't think that setting will affect a string comparison, it will return false after compile
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 500 total points
ID: 39230451
I stand corrected, if I read this correctly, both binary and text options will allow the compare to return a true

Put your Option Compare setting as the first line in your class

From MS:
http://msdn.microsoft.com/en-us/library/8t3khw5f.aspx

 Binary
      

Optional. Results in string comparisons based on a sort order derived from the internal binary representations of the characters.

This type of comparison is useful especially if the strings can contain characters that are not to be interpreted as text. In this case, you do not want to bias comparisons with alphabetical equivalences, such as case insensitivity.

Text
      

Optional. Results in string comparisons based on a case-insensitive text sort order determined by your system's locale.

This type of comparison is useful if your strings contain all text characters, and you want to compare them taking into account alphabetic equivalences such as case insensitivity and closely related letters. For example, you might want to consider A and a to be equal, and Ä and ä to come before B and b.
0
 

Author Comment

by:lrbrister
ID: 39230457
UnifiedUS,
  Does that mean that if I have a Function like below
And pass in HookSwitch

After compile I get
MessageTypes.Unhandled

  Public Function SendProcStatus(ByVal inbStream As String) As MessageTypes
        Select Case inbStream
            Case "ServiceInitiated"
                Return MessageTypes.ServiceInitiated
            Case "Originated"
                Return MessageTypes.Originated
            Case "Delivered"
                Return MessageTypes.Delivered
            Case "Established"
                Return MessageTypes.Established
            Case "NetworkReached"
                Return MessageTypes.NetworkReached
            Case "Diverted"
                Return MessageTypes.Diverted
            Case "PrivateEvent"
                Return MessageTypes.PrivateEvent
            Case "Held"
                Return MessageTypes.Held
            Case "Retrieved"
                Return MessageTypes.Retrieved
            Case "Transferred"
                Return MessageTypes.Transferred
            Case "Queued"
                Return MessageTypes.Queued
            Case "Hookswitch"
                Return MessageTypes.HookSwitch
            Case "DoNotDisturb"
                Return MessageTypes.DoNotDisturb
            Case "ConnectionCleared"
                Return MessageTypes.ConnectionCleared
            Case "MonitorStartResponse"
                Return MessageTypes.MonitorStartResponse
            Case "Failed"
                Return MessageTypes.Failed
            Case Else
                Return MessageTypes.Unhandled
        End Select
    End Function

Open in new window

0
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 39230485
Did you put "option Compare Binary" at the top of the code above the class declaration?

Option Compare Binary
public class...

Another option would be to force the string to an upper case and then compare

Change the select to:
 Select Case inbStream.ToUpper

Then make all your case statements use the upper case as well.
case "HOOKSWITCH"
0
 

Author Closing Comment

by:lrbrister
ID: 39230534
That works fine.
The link pointed out that in the Project Properties you can set the Option COmpare in the Complie pane
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now