Results 1 to 14 of 14

Thread: SetPropertyByName?

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    SetPropertyByName?

    What I need is basically this:

    Code:
    Sub ApplyProperty(iObject As Object, iName As String, iValue As Variant)
        With iObject
            Select Case LCase(iName)
            Case "x": .Left = CLng(iValue)
            Case "y": .Top = CLng(iValue)
            Case "w": .Width = CLng(iValue)
            Case "h": .Height = CLng(iValue)
            
            Case "text": .Text = CStr(iValue)
            Case "caption": .Caption = CStr(iValue)
            End Select
        End With
    End Sub
    
    'Code improved by vBulletin Tool 2.0
    I'm sure you know what I mean.. now is there a direct way to do this? Something like a CallByName function for properties?

    Thanks,

    Fox

  2. #2
    Zaei
    Guest
    Simple:

    In your class:
    Code:
    Private myData as Variant
    
    Public Property Let Data(dat as Variant)
       myData = dat
    End Property
    That will be clsTest.
    In your form:
    Code:
    Private x as clsTest
    
    Private Sub Form_Load()
       CallByName x, "Data", vbLet, 33
    End Sub
    You can use CallByName, because Properties ARE functions in disguise.

    Z.

  3. #3

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    I know that, sorry I didn't mentioned I want to set properties of the existing controls (TextBox, Label, aso.)

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It would work in the same way!
    VB Code:
    1. Sub ApplyProperty(iObject As Object, iName As String, iValue As Variant)
    2.     CallByName iObject, iName, vbLet, iValue
    3. End Sub
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Zaei
    Guest
    Correct, Sas. =)

    Z.

  6. #6
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Yeah if it wasn't for that function, my scripting language would have taken twice the time to develop, and would probably be a lot less organized

    Hey Fox, when are you goint to update your site?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  7. #7

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    ah right, must be my mistake when I tried that and got an error

    site? which site? *g

    well i'm working on my personal site ATM, ever visited http://fox.acky.net/ again?

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Darn, I can't read German!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    I can read it, I just don't understand it (lame joke)

    So you quit programming then?...
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  10. #10

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    sure not see the Visual Basic link in the top-framed menu?

    My whole old site is now a part of the new one, you can directly access it here:

    http://fox.acky.net/vb/

    you know.. once a programmer - always a porgrammer

  11. #11
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    You mean, a poor-grammar? (Sorry, another lame joke hehe )

    But it doesn't have anything new, does it? Weren't you working on a game or something?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  12. #12

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    no nothing new

    im still working on that game, that's another cause why I don't update the site anymore.. just have no time (a wonder I was able to get the private site up )

  13. #13
    Member
    Join Date
    Dec 2001
    Location
    ny
    Posts
    38
    Yeah if it wasn't for that function, my scripting language would have taken twice the time to develop, and would probably be a lot less organized
    Ah, I know what you mean. That function sure saved a hell of a lot of time.

  14. #14
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Yeah. And if your game uses classes, it can easily access the properties of each unit, the map, etc
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

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