Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Select Case not allowing variable to be used

Posted on 2013-06-26
3
Medium Priority
?
278 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses
Course of the Month20 days, 19 hours left to enroll

810 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