Results 1 to 3 of 3

Thread: User defined types?????

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Angry

    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
    Matt

  2. #2
    Guest
    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.
    Code:
    Private Type PLAYER
        X As Integer
        Y As Integer
        Hitpoints As Integer
        Strength As Integer
        Defence As Integer
        Level As Integer
    End Type
    Because we have that template we can now create "copies" of it and assign values to it.
    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
    If we want more player's, we can create more.
    Code:
    Dim Player2 As PLAYER
    Dim Player3 As PLAYER

  3. #3

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Thumbs up

    Thanks megatron that cleared up alot of my questions!!
    Matt

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