+ Reply to Thread
Results 1 to 3 of 3

Error: End Select without Select Case

Hybrid View

RGrunden Error: End Select without... 11-28-2012, 12:14 PM
RHCPgergo Re: Error: End Select without... 11-28-2012, 12:17 PM
RGrunden Re: Error: End Select without... 11-28-2012, 02:34 PM
  1. #1
    Registered User
    Join Date
    04-22-2012
    Location
    Syracuse, NY, USA
    MS-Off Ver
    Office 365
    Posts
    61

    Error: End Select without Select Case

    On debug I am receiving the error named in the title of this post. I cannot see why. When I look back at the code it sends me to this function.
    
    Private Function LightChange(Number)
    '/===============================================================
    '/ This function determines which lights to turn on or off
    '/===============================================================
    '/ This function
    '/ - Determines how many lights to turn on or off
    '/===============================================================
    
    '/===============================================================
    '/ Variable Declarations
        Dim LNum As Integer
        Dim LControl As Integer
        
    '/===============================================================
    '/ Variable Value Assignments
        Let LNum = Number
        Let LControl = 1
    
    '/===============================================================
    '/ Light switch decision loop
    '/ Loop Control Variable: LControl is the LCV
    '/ Loop Initialization: At initializaiton LControl is 1
    '/ Loop Update: At each iteration of the loop LControl is incremented
    '/      by 1.
    '/ Loop Termination: At initialization LControl is 1 and is incremented
    '/      by 1 at each iteration of the loop. Eventually LControl will be
    '/      greater than 5 terminating the loop.
        Do While LControl <= 5
            Select Case LControl
                Case 1
                    Switcher LNum
                Case 2
                    If LNum > 20 Then
                        Switcher (LNum - 10)
                    End If
                Case 3
                    If LNum - 1 Mod 10 <> 0 Then
                        Switcher (LNum - 1)
                    End If
                Case 4
                    If LNum Mod 5 <> 0 Then
                        Switcher (LNum + 1)
                    End If
                Case 5
                    If LNum < 50 Then
                        Switcher (LNum + 10)
            End Select
        Loop
    End Function
    And just for completions sake (and because the previous code references it):
    Private Function Switcher(Number)
    '/===============================================================
    '/ This function changes the state of the light indicated by Number
    '/===============================================================
    '/ This function
    '/ - Determines the state of the light
    '/ - Changes the state of the light
    '/===============================================================
    
    '/===============================================================
    '/ Variable Declarations
        Dim LNum As Integer
        Dim State As Boolean
    
    '/===============================================================
    '/ Variable Value Assignment
        Let LNum = Number
    
    '/===============================================================
    '/ State Determination
        If Me.Controls("Light" & LNum).BackColor = RGB(0, 0, 0) Then
            Let State = False
        Else
            Let State = True
        End If
        
    '/===============================================================
    '/ State Change
        If State = True Then
            Me.Controls("Light" & LNum).BackColor = RGB(0, 0, 0)
        Else
            Me.Controls("Light" & LNum).BackColor = RGB(255, 255, 0)
        End If
    
    End Function
    Reality is stranger than fiction.

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Error: End Select without Select Case

    Hi,

    You are missing an "End if" in Case 5.

    edit: you can make the code shorter if you want by writing the if-then structures in the same row. That way you don't need to use End If. Something like this:
    If LNum < 50 Then Switcher (LNum + 10)
    Last edited by RHCPgergo; 11-28-2012 at 12:20 PM. Reason: addtitional info

  3. #3
    Registered User
    Join Date
    04-22-2012
    Location
    Syracuse, NY, USA
    MS-Off Ver
    Office 365
    Posts
    61

    Re: Error: End Select without Select Case

    u_u' Sometimes it's the little things that are missed. tyvm.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1