Hi!

Please show me how to use Property Set members with classes on VbScript.


Thanks..

Re: Property Set by mayayana

mayayana
Tue Aug 17 10:23:19 CDT 2004

It's Property Let. I think that's a common misunderstanding
because "Let" doesn't make much sense while "Set" does.
But Set is just for objects.

Dim sVal

Public Property Get ValueA()
ValueA = sVal
End Property

Public Property Let ValueA(InVal)
sVal = InVal
End Property

That's a simple example that just holds a value
in a variable inside the class. From outside
you'd call:
s = Class.ValueA '-- Get

Class.ValueA = s '-- Let

If the value is an object you can use:

Set Class.ObjectA = s '-- Let
Set s = Class.ObjectA '-- Get

Sample:
http://www.jsware.net/jsware/scripts.html#getlet

--
--
Kevin <zyke@mail.ru> wrote in message
news:O1zdedGhEHA.2916@TK2MSFTNGP12.phx.gbl...
> Hi!
>
> Please show me how to use Property Set members with classes on VbScript.
>
>
> Thanks..
>
>



Re: Property Set by Kevin

Kevin
Wed Aug 18 03:58:27 CDT 2004

Thanks for reply...

I know how to use Property Get/Let with classes on VbScript.
I need a sample code with Property Set.
Please help me ;-)

Thanks..



Re: Property Set by y

y
Wed Aug 18 07:24:49 CDT 2004

"Kevin" <zyke@mail.ru> wrote in message news:OZkAeGQhEHA.3980@TK2MSFTNGP12.phx.gbl...
> Thanks for reply...
>
> I know how to use Property Get/Let with classes on VbScript.
> I need a sample code with Property Set.
> Please help me ;-)
>
I think I get from this sample code Excel VBA Help and modify.
Y Sakuda from JPN

Class PenClass
Private CurrentPen, CurrentColor
Property Get Pen()
Set Pen = CurrentPen
End Property
Property Set Pen(x)
Set CurrentPen = x
End Property
Property Get Pencolor()
Select Case CurrentColor
Case 1: Pencolor = "Red"
Case 2: Pencolor = "Green"
Case Else: Pencolor = "Black"
End Select
End Property
Property Let Pencolor(x)
If x = "Red" Then
CurrentColor = 1
Else
If x = "Green" Then
CurrentColor = 2
Else
CurrentColor = 0
End If
End If
End Property
End Class
Set wpen = New PenClass
Set wpen2 = New PenClass
wpen.Pencolor = "Red"
wscript.echo wpen.Pencolor
Set wpen2.Pen = wpen ' This line invoke Property Set
wpen2.Pen.Pencolor = "Green"
wscript.echo "No2 " & wpen.Pencolor

Re: Property Set by mayayana

mayayana
Wed Aug 18 11:19:03 CDT 2004

Woops. Sorry, I never noticed the Set property before.
Here's an example that sets a class property to the
FSO and then tests it by calling a FSO method:

-------------------------------------------------------------

Dim ClassOb, FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ClassOb = New a1

Set ClassOb.Object1 = FSO
MsgBox ClassOb.WinFolder

Set ClassOb = Nothing
Set FSO = Nothing

Class a1
Dim ObInternal

Sub Class_Terminate()
Set ObInternal = Nothing
End Sub

Public Property Set Object1(Ob)
Set ObInternal = Ob
End Property

Public Property Get WinFolder()
If Not ObInternal is Nothing Then
WinFolder = ObInternal.GetSpecialFolder(1)
End If
End Property

End Class

-------------------------------------------------------

> Thanks for reply...
>
> I know how to use Property Get/Let with classes on VbScript.
> I need a sample code with Property Set.
> Please help me ;-)
>
> Thanks..
>
>



Re: Property Set by Kevin

Kevin
Wed Aug 25 05:43:41 CDT 2004

Thanks all for the help... ;-)
I understood :-)