|
-
Nov 23rd, 2014, 09:07 AM
#1
Thread Starter
Lively Member
Diffrence between enum and type
What's difference between Enum and type in VB.NET?
-
Nov 24th, 2014, 12:01 PM
#2
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.
-
Nov 24th, 2014, 03:10 PM
#3
Thread Starter
Lively Member
Re: Diffrence between enum and type
 Originally Posted by dday9
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 ?!
-
Nov 24th, 2014, 03:21 PM
#4
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
-
Nov 24th, 2014, 03:44 PM
#5
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
-
Nov 24th, 2014, 07:38 PM
#6
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.
-
Nov 24th, 2014, 09:45 PM
#7
Re: Diffrence between enum and type
 Originally Posted by szlamany
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.
-
Nov 24th, 2014, 10:10 PM
#8
Re: Diffrence between enum and type
 Originally Posted by Mehdi Jazini
...
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|