Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert Short Class Code From C# to VB.NET

Posted on 2007-03-29
3
Medium Priority
?
240 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 2000 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
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…

705 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