Simple parsing question

Posted on 2004-11-17
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 !!

Question by:Akula
    LVL 4

    Accepted Solution

    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

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

    LVL 4

    Assisted Solution

    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
    LVL 1

    Author Comment

    Thanks willcode; that is exactly what I needed!!

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


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    733 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

    17 Experts available now in Live!

    Get 1:1 Help Now