In c# this seems to work fine but in VBS it chucks errors,
can anyone explain why and how to correct please.

Class MyClass

Private tall
Private fat

Private Sub Class_Initialize
tall = 100
fat = 100
End Sub

Public Property Get Height
Height = tall
End Property

Public Property Get Weight
Weight = fat
End Property

Public Property Set Height( temp )
If Not IsNumeric( temp ) Then
tall = CInt( temp )
Else
tall = temp
End If
End Property

Public Property Set Weight( temp )
If Not IsNumeric( temp ) Then
fat = CInt( temp )
Else
fat = temp
End If
End Property

End Class

Set test = new MyClass

test.Height = 190

WScript.Echo "Test's Height is: " & test.Height & vbCrlf &_
"Test's Weight is: " & test.Weight

Re: VBS Class Issues by Ray

Ray
Wed Jul 30 06:39:23 CDT 2003

Try using the LET statement instead of SET.
Public Property Let...

Ray at home

--
Will trade ASP help for SQL Server help


"Jason" <mail_bogus@yahoo.com.au> wrote in message
news:08ad01c3567b$b4981de0$a601280a@phx.gbl...
> In c# this seems to work fine but in VBS it chucks errors,
> can anyone explain why and how to correct please.
>
> Class MyClass
>
> Private tall
> Private fat
>
> Private Sub Class_Initialize
> tall = 100
> fat = 100
> End Sub
>
> Public Property Get Height
> Height = tall
> End Property
>
> Public Property Get Weight
> Weight = fat
> End Property
>
> Public Property Set Height( temp )
> I



Re: VBS Class Issues by Ray

Ray
Wed Jul 30 07:42:06 CDT 2003

VB also uses let. If you pasted this code into a class module, you'd have
to change to let also. Set is for instantiating object variables, in VB*.
It doesn't matter much, since you'll be going to .net and it'll all be
different again. :]

Ray at work

"Jason" <mail_bogus@yahoo.com.au> wrote in message
news:49e701c35691$e81717a0$a001280a@phx.gbl...
> Thanks that seems to work.
> But why all other languages including VB use SET weird.
>
> >-----Original Message-----
> >Try using the LET statement instead of SET.
> >Public Property Let...
> >
> >Ray at home
> >
> >--
> >Will trade ASP help for SQL Server help
> >
> >
> >"Jason" <mail_bogus@yahoo.com.au> wrote in message
> >news:08ad01c3567b$b4981de0$a601280a@phx.gbl...
> >> In c# this seems to work fine but in VBS it chucks
> errors,
> >> can anyone explain why and how to correct please.
> >>
> >> Class MyClass
> >>
> >> Private tall
> >> Private fat
> >>
> >> Private Sub Class_Initialize
> >> tall = 100
> >> fat = 100
> >> End Sub
> >>
> >> Public Property Get Height
> >> Height = tall
> >> End Property
> >>
> >> Public Property Get Weight
> >> Weight = fat
> >> End Property
> >>
> >> Public Property Set Height( temp )
> >> I
> >
> >
> >.
> >



Re: VBS Class Issues by mayayana

mayayana
Wed Jul 30 07:49:29 CDT 2003




> Thanks that seems to work.
> But why all other languages including VB use SET weird.
>

VB uses Let as well. Let for property assignment. Set for
assigning an object reference.


> Public Property Set Height( temp )
> If Not IsNumeric( temp ) Then
> tall = CInt( temp )
> Else
> tall = temp
> End If
> End Property

There is only a variant datatype in VBS. IsNumeric is
not telling you whether the datatype is a numeric type;
it's telling you whether the variable's content can be
interpreted as a number. So if IsNumeric = False then
invalid data was sent.

IsNumeric(22) = true
IsNumeric("22") = True
IsNumeric("twenty two") = false