?
Solved

Select Case not allowing variable to be used

Posted on 2013-06-26
3
Medium Priority
?
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 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