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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:54:21+00:00 2026-05-28T17:54:21+00:00

Is it possible to define a user-defined type constant at module level? Type MyType

  • 0

Is it possible to define a user-defined type constant at module level?

Type MyType
    name as String
    description as String
End Type

' Something like this
Private Const OneType as MyType = "Name" "Description" 
  • 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-28T17:54:22+00:00Added an answer on May 28, 2026 at 5:54 pm

    No. Const does not work with user-defined-types. The closest you can come is to create a class that only has property gets.

    Public Property Get Name() As String
       Name = "Name"
    End Property
    
    Public Property Get Description() As String
       Description = "Description"
    End Property
    

    If you want to have multiple instances of the class with different values but still want the values to be constant, then add an initialize routine that can only be used once.

    Private sName As String
    Private sDescription As String
    
    Private Sub Class_Initialize()
       sName = ""
    End Sub
    
    Public Sub Initialize(Name As String, Description As String)
       If Len(sName) = 0 Then
          sName = Name
          sDescription = Description
       Else
          MsgBox "This instance of MyClass is already initialized!"
       End If
    End Sub
    
    Public Property Get Name() As String
       Name = sName
    End Property
    Public Property Get Description() As String
       Description = sDescription
    End Property
    

    then declare an instance of your class.

    Dim cMyClass1 As New MyClass, cMyClass2 as New MyClass
    cMyClass1.Initialize("Name","Description")
    cMyClass2.Initialize("DiffName","OtherDescription")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In VBP its possible to define user defined actions by creating a custom COM
Is it possible that a multi-statement UDF return a User Defined Table Type, instead
Is it possible to use the Type.<T> syntax with user defined classes? For example,
From a typical store like this Ext.define('User', { extend: 'Ext.data.Model', fields: [ {name: 'firstName',
is it possible to have a User Defined Type inside Oracle package definition? When
Is it possible to get a list of the user defined functions in JavaScript?
Possible Duplicate: User control javascript I defined a JavaScript function inside a user control.
If a pointer to an user defined type is passed as template argument to
Here's my user-defined table type... CREATE TYPE [dbo].[FooType] AS TABLE( [Bar] [INT], ) This
I want to define a Nibble type. I want that if the user sets

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.