Solved

Visual Studio Option Compare

Posted on 2013-06-07
5
481 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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