Solved

Select Case not allowing variable to be used

Posted on 2013-06-26
3
259 Views
Last Modified: 2013-06-26
Hello,

I have some code that depending on the day of the week a certain query is created:

Select Case Today.dayofweek

     Case 1
          ProEnroll = From pe In Me.DataWorkspace.ApplicationData.PaidProgramsEnrollments
               Where pe.ProgramName = pp.ProgramName andAlso pe.Monday = True

     Case 2
          ProEnroll = From pe In    Me.DataWorkspace.ApplicationData.PaidProgramsEnrollements
                Where pe.ProgramName = pp.ProgramName andAlso pe.Tuesday = True

End Select

When I go to use ProEnroll, intellisense does not recognize it.  If it was not in a Select Case structure Intellisense would recognize it.  How can I get around this.

Thanks
0
Comment
Question by:EDozier
  • 2
3 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39279880
Where/how did  you declare ProEnroll?
0
 

Author Comment

by:EDozier
ID: 39279964
kaufmed,

I did not declare it.  Here is code just before the statement I previously included that works:

Dim ProgramQuery = From p In Me.DataWorkspace.ApplicationData.PaidProgramsSet
          Order By p.ProgramName

This variable is not declared but intellisense picks it up and I have access to that entity set.
However, I'm open to any viable option that will move me forward.

EDozier
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39280035
If you did not declare the variable, and you are relying solely on implicit declaration, then your variables only exist within the scope within which they appear--that is, within each CASE statement. You need to widen the scope of the variable. Try declaring the variable outside of your SELECT.

e.g.

Dim ProEnroll As IEnumerable(Of {the type of objects that ProgramsEnrollments contains})

Select Case Today.dayofweek

...

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 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

19 Experts available now in Live!

Get 1:1 Help Now