PDA

Click to See Complete Forum and Search --> : display class object


shucus
Aug 19th, 2005, 07:07 AM
why there is a problem in this code??
i want to display the Clock object

Class Clock
public Second as integer
public Minute as integer
public Hour as integer

sub SetTime(intSec as integer, intMin as integer, intHour as integer)
Second = intSec
Minute = intMin
Hour = intHour
end sub

sub ShowTime()
dim showClock as new Clock
Response.Write(showClock.Second)
end sub
End Class

sub Page_Load(obj as object, e as eventargs)
dim objClock as new Clock
objClock.SetTime(60,4,12)
objClock.ShowTime

end sub
</script>
<body MS_POSITIONING="GridLayout">
</body>
</HTML>

techgnome
Aug 19th, 2005, 07:25 AM
Well... here's what jumps out at me.

1) dim showClock as new Clock <-- I don't think you can define a variable of a class inside the class....
2) ShowTime only shows the seconds.... but it's the seconds property of the object it can't create.

Tg