Solved

Select Case not allowing variable to be used

Posted on 2013-06-26
3
260 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 75

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 75

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
A short film showing how OnPage and Connectwise integration works.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

911 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

23 Experts available now in Live!

Get 1:1 Help Now