Results 1 to 4 of 4

Thread: re:enum and memory space

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Location
    Here and There
    Posts
    92

    re:enum and memory space

    Hi what I'd like to know is
    if I have a project which incoporporates an enum with say 7 elements declared for it , ie enum weekday (sun, mon,tues..........sat).

    how can I
    firstly find the address of where the enum is in memory? (like an array has an address of where it starts in memory)

    secondly, how can I ascertain the number of elements? (I know that UBound can be used for arrays etc , is there something similar?)
    ab uno disce omnes

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: enum and memory space

    Moved from FAQ forum

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Location
    Here and There
    Posts
    92

    Re: enum and memory space (oops)

    FIRSTLY, I WISH TO APOLOGISE FOR POSTING IN THE WRONG FORUM !! (SORRY)

    I have made an attempt to ascertain the address of enums when declared (run time). I need a method now to be able to access the memory locations of the individual elements (and contents of each) of each enum declared. ie. I want to be able to retrieve the memory locations of the 5 elements.... Please can someone help?

    Declare this in module
    VB Code:
    1. Declare Function VarPtrAny Lib "vb60032.dll" Alias "VarPtr" (lpObject As Any) As Long
    2.  
    3. 'Put this bit in form
    4.  
    5. Option Explicit
    6. Private Ptr1 As Long
    7.  
    8. Private Enum WorkDays1
    9. Monday
    10. Tuesday
    11. Wednesday
    12. Thursday
    13. Friday
    14. End Enum
    15.  
    16. Private Sub Form_Load()
    17. Dim lngDay1 As WorkDays1
    18.  
    19. Ptr1 = VarPtr(lngDay1)
    20. Debug.Print Ptr1
    21. End Sub
    Last edited by Hack; Feb 9th, 2006 at 10:43 AM. Reason: Added [vbcode] [/vbcode] tags for more clarity.
    ab uno disce omnes

  4. #4

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