Solved

Convert Short Class Code From C# to VB.NET

Posted on 2007-03-29
3
236 Views
Last Modified: 2010-08-05
Could someone help convert the following code into VB.NET so I can understand and use/extend it.

// Class to hold setting information
public class ClockSetting
{
    private int _someValue;public ClockSetting() { }
    public int SomeValue
    {
        get{ return _someValue; }
        set{ _someValue = value; }
    }
}

// This class inherits from ApplicationSettingsBase.
// The only property being persisted
// is a collection of ClockSetting objects.
// This allows the settings for each clock
// created by the user to be stored and loaded with minimal coding.
public class TimePieceSettings : ApplicationSettingsBase
{
    [UserScopedSetting()]
    public List<ClockSetting> ClockSettings
    {
        get { return (List<ClockSetting>)this["ClockSettings"]; }
        set { this["ClockSettings"] = (List<ClockSetting>)value; }
    }
}
// Loading the settings
_settings = new TimePieceSettings();
foreach (ClockSetting setting in _settings.ClockSettings)
{
    AddClock(setting);
}
//Saving the settings
foreach(Clock clock in _layoutPanel.Controls)
{
    ClockSetting instance = CreateSetting(clock);
    _settings.ClockSettings.Add(instance);
}
_settings.Save();
0
Comment
Question by:endrec
[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 35

Expert Comment

by:mrichmon
ID: 18818091
0
 

Author Comment

by:endrec
ID: 18818272
These converters will not work on the code above.
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 18818568
The only thing the converters didn't like is the Generic Lists because of the < >

Here:

Public Class ClockSetting
    Private Integer _someValue
    Public  Sub New()
    End Sub
    Public Property SomeValue() As Integer
          Get
               Return _someValue
          End Get
          Set (ByVal Value As Integer)
               _someValue = value
          End Set
    End Property
End Class

public class TimePieceSettings Inherits ApplicationSettingsBase
<UserScopedSetting()>
Public Property ClockSettings As List(Of ClockSetting)
Get
Return (List(Of ClockSetting))this("ClockSettings")
End Get
Set (ByVal Value As List(Of ClockSetting))
this("ClockSettings") = value
End Set
End Property
End Class

Dim setting As ClockSetting
For Each setting In _settings.ClockSettings
    AddClock(setting)
Next
'Saving the settings
Dim clock As Clock
For Each clock In _layoutPanel.Controls
    Dim instance As ClockSetting =  CreateSetting(clock)
    _settings.ClockSettings.Add(instance)
Next
_settings.Save()

0

Featured Post

Industry Leaders: 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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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