By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,083 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,083 IT Pros & Developers. It's quick & easy.

class problem, How to get data from class

P: n/a
i'm stuck with a class problem, i want to create a class that, say for
example gets the system time, and can be displayed in label or textbox but
can be accessed many times....

ok i'll start with a pseudo example.

VB.NET
pseudo code....

public function test(variable)
do something....anything
eg get system date,time or anything
'**********************
label1.text=result 'This works here, but not in a class?
'**********************
end function

private sub form load
timer1.interval=500
timer1.enabled=true
end sub

private sub timer1_tick()
dim x as integer
test(x)
end sub

'This works fine but i want to put this in class so, it can be accessed many
times.

class myclass
'maybe withevents of inherits timer1, not sure
public function test(variable)
do something....anything

'****problem here******

label1.text=result 'this will not work but to put in its place?

'*******************
end function
private sub timer1_tick()
dim x as integer
test(x)
end sub
end class

i cant figure out how to bring the data out of the class, for example if the
data in displayed in a label, and use it to have say tens or thousands of
labels that display this data, how do i extract it from the class.
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sympatico,

The timers (there are 3 of those which are) are alarmclocks.

For your system time is enough,
Dim dt As DateTime = Now
MessageBox.Show(dt.ToString("hh:mm"))

In my opinion is using a class for this the wrong use of OOP.

I cannot find any reason for it, in contradiction, it makes the program less
readable and process slower, although that last is in my opinion not
important for this.

I hope this helps?

Cor

"sympatico" <fe******@a1vbcode.com>
i'm stuck with a class problem, i want to create a class that, say for
example gets the system time, and can be displayed in label or textbox but
can be accessed many times....

ok i'll start with a pseudo example.

VB.NET
pseudo code....

public function test(variable)
do something....anything
eg get system date,time or anything
'**********************
label1.text=result 'This works here, but not in a class?
'**********************
end function

private sub form load
timer1.interval=500
timer1.enabled=true
end sub

private sub timer1_tick()
dim x as integer
test(x)
end sub

'This works fine but i want to put this in class so, it can be accessed
many
times.

class myclass
'maybe withevents of inherits timer1, not sure
public function test(variable)
do something....anything

'****problem here******

label1.text=result 'this will not work but to put in its place?

'*******************
end function
private sub timer1_tick()
dim x as integer
test(x)
end sub
end class

i cant figure out how to bring the data out of the class, for example if
the
data in displayed in a label, and use it to have say tens or thousands of
labels that display this data, how do i extract it from the class.

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.