|
-
Dec 7th, 2001, 08:10 AM
#1
Thread Starter
PowerPoster
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
-
Dec 7th, 2001, 08:36 AM
#2
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.
-
Dec 7th, 2001, 08:55 AM
#3
Thread Starter
PowerPoster
I know that, sorry I didn't mentioned I want to set properties of the existing controls (TextBox, Label, aso.)
-
Dec 7th, 2001, 01:26 PM
#4
Good Ol' Platypus
It would work in the same way!
VB Code:
Sub ApplyProperty(iObject As Object, iName As String, iValue As Variant)
CallByName iObject, iName, vbLet, iValue
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)
-
Dec 7th, 2001, 02:28 PM
#5
-
Dec 7th, 2001, 06:08 PM
#6
-
Dec 9th, 2001, 07:25 AM
#7
Thread Starter
PowerPoster
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?
-
Dec 9th, 2001, 08:05 AM
#8
Good Ol' Platypus
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)
-
Dec 9th, 2001, 01:29 PM
#9
Frenzied Member
I can read it, I just don't understand it (lame joke)
So you quit programming then?...
-
Dec 9th, 2001, 04:41 PM
#10
Thread Starter
PowerPoster
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
-
Dec 9th, 2001, 04:52 PM
#11
Frenzied Member
-
Dec 10th, 2001, 01:58 AM
#12
Thread Starter
PowerPoster
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 )
-
Dec 10th, 2001, 04:31 PM
#13
Member
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.
-
Dec 12th, 2001, 09:17 AM
#14
Frenzied Member
Yeah. And if your game uses classes, it can easily access the properties of each unit, the map, etc
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|