Results 1 to 5 of 5

Thread: Dynamic Type Variable

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Lightbulb

    Hi, is there a way of dynamically indicating what the variable names are in a type. Say I have:
    Type Employee
    FName as string
    MName as string
    LName as string
    Addr1 as string
    (and so on)
    End Type
    Say these names match fields in a database table. If I later add a new field in the table (Email, for example), I want to add to the Employee type: Email as string

    Is there a way to do this without opening the code again and installing updates? I know when you read a recordset, you can dynamically determine the field names.

    Thanks in advance.

    Wade

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You could create a dynamic array of strings, but that means you can't have those names
    Code:
    Type Employee
      a() as string
    End type
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    If I did that, is there a way of dynamically setting the variable type (I'm thinking no), or at least a way of deallocating memory from variables that aren't needed -- say I make 12 string variables but only need 8 initially.

    Thanks.
    Wade
    Wade

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You can redimension your string array
    Code:
    DIm b as Employee
    redim b.a(8)
    
    'Then later you could do:
    Redim preserve b.a(12)
    'If you want to deallocate:
    Erase b.a
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    It's not perfect, but it's progress. Thanks

    Wade

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