Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8853715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:43:08+00:00 2026-06-14T13:43:08+00:00

I need to create a property in a class that will give the programmer

  • 0

I need to create a property in a class that will give the programmer a list of values to choose from. I have done this in the past using the enums type.

Public Enum FileType
    Sales
    SalesOldType
End Enum

Public Property ServiceID() As enFileType
    Get
        Return m_enFileType
    End Get
    Set(ByVal value As enenFileType)
        m_enFileType = value
    End Set
End Property

The problem is I would like to populate the list of values on init of the class based on SQL table values. From what I have read it is not possible to create the enums on the fly since they are basically constants.

Is there a way I can accomplish my goal possibly using list or dictionary types?
OR any other method that may work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:43:09+00:00Added an answer on June 14, 2026 at 1:43 pm

    If the values aren’t going to change after the code is compiled, then it sounds like the best option is to simply auto-generate the code. For instance, you could write a simple application that does something like this:

    Public Shared Sub Main()
        Dim builder As New StringBuilder()
        builder.AppendLine("' Auto-generated code.  Don't touch!!  Any changes will be automatically overwritten.")
        builder.AppendLine("Public Enum FileType")
        For Each pair As KeyValuePair(Of String, Integer) In GetFileTypesFromDb()
            builder.AppendLine(String.Format("    {0} = {1}", pair.Key, pair.Value))
        End For
        builder.AppendLine("End Enum")
        File.WriteAllText("FileTypes.vb", builder.ToString())
    End Sub
    
    Public Function GetFileTypesFromDb() As Dictionary(Of String, Integer)
        '...
    End Function
    

    Then, you could add that application as a pre-build step in your project so that it automatically runs each time you compile your main application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one aspx Page from that i need to access the property
I have a need to create a couple of classes that will serve as
I have an abstract class that other classes are inheriting this. public abstract class
Im trying to create a PNG sequencer class that will allow me to change
I have GraphicView class that inherits from UIView. Its initWithFrame method is: @implementation GraphicsView
This can be done in a million ways ... Problem. I have a list
I'm creating a class that will store data in a file and I need
I need to create a property tha will hold to ints for example int
I have the following view model: Public Class MyViewModel Public Property SelectedIDs As List(Of
I'd like to create a CustomWindow class that behaves this way: 1. Non-client area

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.