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 3228170
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:39:38+00:00 2026-05-17T16:39:38+00:00

I know this is a proper enum: Private Enum Months JANUARY = 1 FEBRUARY

  • 0

I know this is a proper enum:

Private Enum Months
  JANUARY = 1
  FEBRUARY = 2
  ...
End Enum

However, I want to have an enum where the string will solely be integers.

Example:

Private Enum ColumnCounts
  01 = 5
  02 = 4
  03 = 40
End Enum

The 01, 02 and 03 are all strings. However, if I put “01”, [01] or just 01, it tells me it expects the end of the Enum and that it isn’t a valid statement. Is there any way to accomplish this that I’m missing? I even tried. 01.ToString(), but that wasn’t an option. 🙂 Any and all help is appreciated. Thanks.

Edit:

Public Class Part

  Private Enum ColumnCounts
    f01 = 39
  End Enum

  Public Shared Function ValidateColumns(ByRef lstFields As List(Of String)) As Boolean
    For Each colCount In [Enum].GetValues(GetType(ColumnCounts))
      If colCount = "f" + lstFields(1) Then
        'Right here I need to compare the count of the list vs. the value of the enum.'
        Return True
      End If
    Next

    Return False
  End Function
End Class

Essentially, I didn’t want to put the f in there, just wanted to do 01. The way this will be called is:

Select Case (nRecordType)
  Case "01"
    ...
  Case "02"
    ...
  Case "03"
    Return Part.ValidateColumns(_lstFields)
End Select

Because I’m not making an instance of it and not calling a constructor, there’s no way to autopopulate a Dictionary. And I don’t want to convert to integer so I’m not going to do an array. That is just in case eventually the value gets above 99 and the next value would be A0. I’m trying to think of easy future changes to this and backwards compatability. If you need more explanations, let me know.

Edit 2:

This is what I’ve done now and I think it should work:

Public Class Part

  Private Shared columnCounts As Dictionary(Of String, Integer) = New Dictionary(Of String, Integer)

  Public Shared Function ValidateColumns(ByRef lstFiels As List(Of String)) As Boolean
    InitializeColumnDictionary()

    Return lstFields.Count = columnCounts(lstFields(1))
  End Function

  Private Shared Sub InitializeColumnDictionary()
    columnCounts.Add("01", 39)
  End Sub
End Class

I’m not at a point where I can test it right now so I can’t verify that it’s going to do what I want to, but it doesn’t give me an error when I build it so I’m crossing my fingers.

  • 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-05-17T16:39:39+00:00Added an answer on May 17, 2026 at 4:39 pm

    Integers alone are NOT valid identifiers.
    Why would you want to call 01 an identifier?
    Prefix the enum elements with a letter, and you’re done:

    i01,
    i02
    ...
    

    edit as per your editing:
    declare a static dictionary and populate it, if it’s null, in your static method:

    private static void yourMethod()
            {
                if (ColumnCounts == null)
                {
                    ColumnCounts = new Dictionary<String, int>();
                    ColumnCounts.Add("01", 39);
                    ColumnCounts.Add("02", 45);
                    ColumnCounts.Add("03", 12);
                    ColumnCounts.Add("04", 0);
                }
    
    
    
    
            }
    
    
    
            private static Dictionary<String, int> ColumnCounts = null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.