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

How to update label.txt from a module????

P: n/a
In my program I have several labels that I want to update with
information that is being processed in a calculation module. I have
code similar to the following in my module. As it goes through its
process, I would like to show an update to the counts that are being
generated to show progress.

Code in a module........
cntClasses = cntClasses + 1
cntTrials = cntTrials + 3

Form1.lblCntClasses.Text = Format(cntClasses, "###,###")
Form1.lblCntTrials.Text = Format(cntTrials, "###,###")

End Code.......

I get errors on the "Form1.lbl......" statements which says "Reference
to a non-shared member requires an object reference.".

How do I rectify this? Do I have to refresh Form1 again?

Code examples or suggestions?

Sorry for the newbie questions.

Hexman
Nov 29 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hexman wrote:
In my program I have several labels that I want to update with
information that is being processed in a calculation module. I have
code similar to the following in my module. As it goes through its
process, I would like to show an update to the counts that are being
generated to show progress.

Code in a module........
cntClasses = cntClasses + 1
cntTrials = cntTrials + 3

Form1.lblCntClasses.Text = Format(cntClasses, "###,###")
Form1.lblCntTrials.Text = Format(cntTrials, "###,###")

End Code.......

I get errors on the "Form1.lbl......" statements which says "Reference
to a non-shared member requires an object reference.".

How do I rectify this? Do I have to refresh Form1 again?

Code examples or suggestions?

Sorry for the newbie questions.

Hexman


you either have to pass a reference to the form and make a property to
edit it, or pass the label into the module.

chris
Nov 29 '05 #2

P: n/a
On Mon, 28 Nov 2005 22:40:28 -0500, I Don't Like Spam <no@spam.com>
wrote:
Hexman wrote:
In my program I have several labels that I want to update with
information that is being processed in a calculation module. I have
code similar to the following in my module. As it goes through its
process, I would like to show an update to the counts that are being
generated to show progress.

Code in a module........
cntClasses = cntClasses + 1
cntTrials = cntTrials + 3

Form1.lblCntClasses.Text = Format(cntClasses, "###,###")
Form1.lblCntTrials.Text = Format(cntTrials, "###,###")

End Code.......

I get errors on the "Form1.lbl......" statements which says "Reference
to a non-shared member requires an object reference.".

How do I rectify this? Do I have to refresh Form1 again?

Code examples or suggestions?

Sorry for the newbie questions.

Hexman


you either have to pass a reference to the form and make a property to
edit it, or pass the label into the module.

chris


Currently I have 6 labels that I want updated on the form, with more
to come. Any preference to either of the methods you mentioned? Any
code snippet of either?

Thanks,

Hexman
Nov 29 '05 #3

P: n/a
Hexman wrote:
On Mon, 28 Nov 2005 22:40:28 -0500, I Don't Like Spam <no@spam.com>
wrote:

Hexman wrote:
In my program I have several labels that I want to update with
information that is being processed in a calculation module. I have
code similar to the following in my module. As it goes through its
process, I would like to show an update to the counts that are being
generated to show progress.

Code in a module........
cntClasses = cntClasses + 1
cntTrials = cntTrials + 3

Form1.lblCntClasses.Text = Format(cntClasses, "###,###")
Form1.lblCntTrials.Text = Format(cntTrials, "###,###")

End Code.......

I get errors on the "Form1.lbl......" statements which says "Reference
to a non-shared member requires an object reference.".

How do I rectify this? Do I have to refresh Form1 again?

Code examples or suggestions?

Sorry for the newbie questions.

Hexman


you either have to pass a reference to the form and make a property to
edit it, or pass the label into the module.

chris

Currently I have 6 labels that I want updated on the form, with more
to come. Any preference to either of the methods you mentioned? Any
code snippet of either?

Thanks,

Hexman


Why is this code in a module? Why not have the code in the form? Both
of those are preffered ways. To pass the form into a function just do
it like any other call:

Public sub XYZ(F as FormClass)
f.label1text = "String"
end sub

public Class FormClass
public sub CallModule
XYZ(Me)
end sub
end class
Nov 29 '05 #4

P: n/a
Hexman,

Why not use OOP

You have your labels normally on a form and when the user clicks a button
you start to update your labels

In a very very very simplified sample.

\\\\
dim myobject as new myOwnClass(100)
mylabel1 = myobject.mytext1
mylabel2 = myobject.mytext2
///
\\\
Public class MyOwnClass
Public myText1 as String
Public myText2 as Sring
Public sub New (byval PassedToMe as integer)
myText1 = (passedtome*1).ToString
myText2 = (passedtome* 5).ToString
end Sub
///

I hope this gives an idea.

Cor

"Hexman" <He****@binary.com> schreef in bericht
news:1h********************************@4ax.com...
In my program I have several labels that I want to update with
information that is being processed in a calculation module. I have
code similar to the following in my module. As it goes through its
process, I would like to show an update to the counts that are being
generated to show progress.

Code in a module........
cntClasses = cntClasses + 1
cntTrials = cntTrials + 3

Form1.lblCntClasses.Text = Format(cntClasses, "###,###")
Form1.lblCntTrials.Text = Format(cntTrials, "###,###")

End Code.......

I get errors on the "Form1.lbl......" statements which says "Reference
to a non-shared member requires an object reference.".

How do I rectify this? Do I have to refresh Form1 again?

Code examples or suggestions?

Sorry for the newbie questions.

Hexman

Nov 29 '05 #5

P: n/a
On Mon, 28 Nov 2005 23:34:35 -0500, I Don't Like Spam <no@spam.com>
wrote:
Hexman wrote:
On Mon, 28 Nov 2005 22:40:28 -0500, I Don't Like Spam <no@spam.com>
wrote:

Hexman wrote:

In my program I have several labels that I want to update with
information that is being processed in a calculation module. I have
code similar to the following in my module. As it goes through its
process, I would like to show an update to the counts that are being
generated to show progress.

Code in a module........
cntClasses = cntClasses + 1
cntTrials = cntTrials + 3

Form1.lblCntClasses.Text = Format(cntClasses, "###,###")
Form1.lblCntTrials.Text = Format(cntTrials, "###,###")

End Code.......

I get errors on the "Form1.lbl......" statements which says "Reference
to a non-shared member requires an object reference.".

How do I rectify this? Do I have to refresh Form1 again?

Code examples or suggestions?

Sorry for the newbie questions.

Hexman

you either have to pass a reference to the form and make a property to
edit it, or pass the label into the module.

chris

Currently I have 6 labels that I want updated on the form, with more
to come. Any preference to either of the methods you mentioned? Any
code snippet of either?

Thanks,

Hexman


Why is this code in a module? Why not have the code in the form? Both
of those are preffered ways. To pass the form into a function just do
it like any other call:

Public sub XYZ(F as FormClass)
f.label1text = "String"
end sub

public Class FormClass
public sub CallModule
XYZ(Me)
end sub
end class


I have the code in a module because it is a data access module and is
called from several different forms.

Thanks for the example.

Hexman.
Nov 29 '05 #6

P: n/a
On Tue, 29 Nov 2005 08:09:59 +0100, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
Hexman,

Why not use OOP

You have your labels normally on a form and when the user clicks a button
you start to update your labels

In a very very very simplified sample.

\\\\
dim myobject as new myOwnClass(100)
mylabel1 = myobject.mytext1
mylabel2 = myobject.mytext2
///
\\\
Public class MyOwnClass
Public myText1 as String
Public myText2 as Sring
Public sub New (byval PassedToMe as integer)
myText1 = (passedtome*1).ToString
myText2 = (passedtome* 5).ToString
end Sub
///

I hope this gives an idea.

Cor

"Hexman" <He****@binary.com> schreef in bericht
news:1h********************************@4ax.com.. .
In my program I have several labels that I want to update with
information that is being processed in a calculation module. I have
code similar to the following in my module. As it goes through its
process, I would like to show an update to the counts that are being
generated to show progress.

Code in a module........
cntClasses = cntClasses + 1
cntTrials = cntTrials + 3

Form1.lblCntClasses.Text = Format(cntClasses, "###,###")
Form1.lblCntTrials.Text = Format(cntTrials, "###,###")

End Code.......

I get errors on the "Form1.lbl......" statements which says "Reference
to a non-shared member requires an object reference.".

How do I rectify this? Do I have to refresh Form1 again?

Code examples or suggestions?

Sorry for the newbie questions.

Hexman

Thanks for the example. I'll try it.

Thanks,

Hexman

Nov 29 '05 #7

P: n/a
"Hexman" <He****@binary.com> schrieb

Why is this code in a module? Why not have the code in the form?
Both of those are preffered ways. To pass the form into a
function just do it like any other call:

Public sub XYZ(F as FormClass)
f.label1text = "String"
end sub

public Class FormClass
public sub CallModule
XYZ(Me)
end sub
end class


I have the code in a module because it is a data access module and
is called from several different forms.

I agree with Chris. You should better either derive the Forms from a base
Form containing the common controls and put the code there, or put the
controls in a Usercontrol and place it on all your Forms.
Armin

Nov 29 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.