Solved

Convert Short Class Code From C# to VB.NET

Posted on 2007-03-29
3
238 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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…

617 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