Results 1 to 8 of 8

Thread: Diffrence between enum and type

  1. #1

    Thread Starter
    Lively Member Mahdi Jazini's Avatar
    Join Date
    Feb 2014
    Location
    Iran / Tehran
    Posts
    89

    Diffrence between enum and type

    What's difference between Enum and type in VB.NET?

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,371

    Re: Diffrence between enum and type

    An Enum is meant for if you have unchanging values that are related to each other. Enum's can also only return the following data types: Byte, Integer, Long, SByte, Short, UInteger, ULong, or UShort.

    A Type can be thought of the foundation of a programming language. It's the most basic form of a given value.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Lively Member Mahdi Jazini's Avatar
    Join Date
    Feb 2014
    Location
    Iran / Tehran
    Posts
    89

    Re: Diffrence between enum and type

    Quote Originally Posted by dday9 View Post
    An Enum is meant for if you have unchanging values that are related to each other. Enum's can also only return the following data types: Byte, Integer, Long, SByte, Short, UInteger, ULong, or UShort.

    A Type can be thought of the foundation of a programming language. It's the most basic form of a given value.
    Oh my God !!!

    Where is the Type command in VB.Net ?!!!

    Type was a useful command to make user-defined variables in modules and classes...

    an example about Type:

    Code:
    '''''''' In Module1 in a Visual Basic 6 Project '''''''''''
    Public Type test1
        a1 As String
        a2 As Byte
        a3 As String * 3
        a4 As Integer
    End Type
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    
    '''''''' In Form1 in a Visual Basic 6 Project '''''''''''
    
    Private Sub Form_Load()
    
        Dim a_final As test1
        
        a_final.a1 = "test"
        a_final.a2 = 2
        a_final.a3 = "ali"
        a_final.a4 = 6536
        
        MsgBox a_final.a1
        MsgBox a_final.a2
        MsgBox a_final.a3
        MsgBox a_final.a4
        
    End Sub
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Is the Enum equivalent of Type in VB.Net ?!

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,371

    Re: Diffrence between enum and type

    That looks like a class:
    Code:
    Public Class Test1
        Public a1 As String
        Public a2 As Byte
        Public a3 As String '* 3? Don't know what that is...
        Public a4 As Integer
    End Class
    
    Private Sub form_load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.OnLoad()
    
        Dim a_final As Test1 = New Test1 With {.a1 = "test", .a2 = 2, .a3 = "ali", .a4 = 6536}
    
    End Sub
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  5. #5
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Diffrence between enum and type

    There are 5 kinds of 'types' in VB:
    Class
    Structure (this is closer to the 'Type' of VB6)
    Interface
    Enum
    Delegate
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Diffrence between enum and type

    If the values are going to be changing, use a CLASS. If they values are static use a STRUCTURE.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Diffrence between enum and type

    Quote Originally Posted by szlamany View Post
    If the values are going to be changing, use a CLASS. If they values are static use a STRUCTURE.
    Also, regardless of whether you declare a class or structure, don't put anything in a module. Classes, structures and modules are all first-class types so each one would best be declared in its own code file. None of them belong in any of the others except under specific circumstances.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: Diffrence between enum and type

    Quote Originally Posted by Mehdi Jazini View Post
    ...
    Is the Enum equivalent of Type in VB.Net ?!
    No, the Enum in VB.Net is pretty much the same as the Enum in VB6

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width