Can someone please explain what user defined types do. I have researched it and know that it is a variable that hold different data types, but how is it incorperated into a program do you have to assign values to them>?? Thanks in advance
Printable View
Can someone please explain what user defined types do. I have researched it and know that it is a variable that hold different data types, but how is it incorperated into a program do you have to assign values to them>?? Thanks in advance
Here is an example of a UDT for a Role-Playing game. As you can see it's a data-type that contains elements that are essential for the player such as X position, Y postion, Strength, Hitpoints etc.
Because we have that template we can now create "copies" of it and assign values to it.Code:Private Type PLAYER
X As Integer
Y As Integer
Hitpoints As Integer
Strength As Integer
Defence As Integer
Level As Integer
End Type
If we want more player's, we can create more.Code:Private Sub Command1_Click()
Dim Player1 As PLAYER
Player1.Hitpoints = 30
Player1.Strength = 10
Player1.Defence = 5
Player1.X = 10
Player1.Y = 10
End Sub
Code:Dim Player2 As PLAYER
Dim Player3 As PLAYER
Thanks megatron that cleared up alot of my questions!!