[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Select Case not allowing variable to be used

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
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…

650 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