Results 1 to 4 of 4

Thread: Select Case Scope

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    Select Case Scope

    Are duplicate name declarations in a select case legal?

    Code:
    Select Case Msg
        Case "Yes"
            Dim sAnswer As String = "Yes"
        Case "No"
            Dim sAnswer As String = "No"
    End Select
    Reason I ask is because I notice if I do this, the IDE wont automatically format the name of the declaration , like so...

    Code:
    Select Case Msg
        Case "Yes"
            Dim sAnswer As String = "Yes"
            MsgBox(sanswer)
        Case "No"
            Dim sAnswer As String = "No"
            MsgBox(sanswer)
    End Select

    The IDE wont auto-Capitalise sanswer if I have more than 1 instance in the routine.. Just wondering..

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Simple answer : If the project doesn't compile, then its not legal.

    Does it compile?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Select Case Scope

    Originally posted by Hinder
    Are duplicate name declarations in a select case legal?

    Code:
    Select Case Msg
        Case "Yes"
            Dim sAnswer As String = "Yes"
        Case "No"
            Dim sAnswer As String = "No"
    End Select
    Reason I ask is because I notice if I do this, the IDE wont automatically format the name of the declaration , like so...

    Code:
    Select Case Msg
        Case "Yes"
            Dim sAnswer As String = "Yes"
            MsgBox(sanswer)
        Case "No"
            Dim sAnswer As String = "No"
            MsgBox(sanswer)
    End Select

    The IDE wont auto-Capitalise sanswer if I have more than 1 instance in the routine.. Just wondering..


    Have you tried your code? Cos it works OK. as it is.

    If you declare sAnswer outside of the Select Case Block you will find the intellisense works as you expect.
    Last edited by taxes; May 23rd, 2004 at 05:33 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    The IDE's got weird quirks, doesn't mean your code won't work. I.e., if i have an if...end block, then put that in another if...end block, the IDE doesn't always format them out to the correct tabs. Usually they'll be ok the next time I load the project, but anyway, doesn't seem to break the code (that's my job!).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width