[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Simple parsing question

Posted on 2004-11-17
4
Medium Priority
?
423 Views
Last Modified: 2010-04-24
Hi all,
I have a simple yet confusing (for me) question.
I have created a scheduling type of scenario.
I want some code to fire at a certain time on certain days.
Now, here is my dilema:
I have set some values in the registry and I later read from there to determine the day of week.
But, I have this in the registry  1,3,5  for Mon,Wed,Fri.
I then read these values to see if I need to fire the code off.
My code to check:

        Dim WDay As String
        If Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\.....\Value", True).GetValue("Daylog") = 0 Then
            WDay = "Sunday"
        End If
        If Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\.....\Value", True).GetValue("Daylog") = 1 Then
            WDay = "Monday"
        End If
        If Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\.....\Value", True).GetValue("Daylog") = 2 Then
            WDay = "Tuesday"
        End If
        If Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\.....\Value", True).GetValue("Daylog") = 2 Then
            WDay = "Tuesday"
        End If
       If WDay = Date.Now.DayOfWeek.ToString Then
         my code here
      End If

But when it checks and there is more than one number, then nothing happens.
I gues I need to parse the values in some way; or maybe a better way to do this?
Help !!

Ak
0
Comment
Question by:Akula
3 Comments
 
LVL 4

Accepted Solution

by:
willcode4coffee earned 400 total points
ID: 12607641
In the scenerio that you outlined, you should use a comma-delimited list in the registry to store multiple values, then parse them when you read the.

'...code to get registry value and assign it to variable sRegValue....

Dim sDays() As String = sRegValue.Split

Dim sVal As String

For Each sVal in sDays
   MessageBox.Show sVal
Next


This should show a message box for each value in the list.

M@
0
 
LVL 4

Assisted Solution

by:Excalibur_Software
Excalibur_Software earned 400 total points
ID: 12607653
First why all the if's statments
try something like:

Dim Mytest as integer

Mytest = Val(Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\.....\Value", True).GetValue("Daylog") )

Select Case Mytest

   Case 1
      WDay = "Sunday"
   Case 2
      WDay = "Monday"
   Case 3
      WDay = "Tuesday"
Case Else
    'What ever you need to do if the right value is not selected such as setting it to a defualt value or something
End Case

Note this is air code
I hope  this helps
0
 
LVL 1

Author Comment

by:Akula
ID: 12608568
Thanks willcode; that is exactly what I needed!!

Excallibur,
Your code was extremely helpful as well.
I will post a question worth 100 points for you as well.

Ak
0

Featured Post

Technology Partners: 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

830 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