473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

write to a Form label from a class object?

Hello,

If I instantiate a class object from a form I would like
to be able to write to a label on the calling form
something like

"hello from class object"

from within a subroutine inside the class object. Is this
possible?

I tried the following in the class object

Public Class MyClass
Dim frm As New Form1

Sub RunProcess()
....
frm.lbl1.Text = "hello from class object"
Do While ...
.... takes about 5 minutes to run loop
Loop
....
End sub
End Class

If it is possible to write to a label on the calling form
from within the subroutine in my class object, may I ask
what the syntax looks like?

Thanks,
Steve
Nov 21 '05 #1
2 2328
Steve,

Do you mean this?

\\\
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myfiller As New filler
myfiller.sayhello(Me.Label1)
End Sub
///end form
\\\begin class
Public Class filler
Public Sub sayhello(ByVal meControl As Control)
meControl.Text = "hello from class object"
End Sub
End Class
///

Cor

"Steve" <an*******@discussions.microsoft.com>
Hello,

If I instantiate a class object from a form I would like
to be able to write to a label on the calling form
something like

"hello from class object"

from within a subroutine inside the class object. Is this
possible?

I tried the following in the class object

Public Class MyClass
Dim frm As New Form1

Sub RunProcess()
...
frm.lbl1.Text = "hello from class object"
Do While ...
... takes about 5 minutes to run loop
Loop
...
End sub
End Class

If it is possible to write to a label on the calling form
from within the subroutine in my class object, may I ask
what the syntax looks like?

Thanks,
Steve

Nov 21 '05 #2
Yes. Thank you. But what I really want to do is to
display a counter on Form1 from my custom class. The
class object will be retrieving data from a source. Say I
have 1000 records to retrieve. I would like to write the
count of each record to Label1 on Form1, ie: 1, 2, 3, ...
1000. I imagine this should be doable with your example.
Would your example be satisfactory for something like
this? Or is there a way that would be more correct?

I tried this in VB6 with no problem. But in my vb.net app
I have Option Strict on. I am guessing there is late
binding going on in the VB6 app. In the vb6 class I say

Class1
Dim frm As Form
Sub SayHello()
Set frm = Form1
frm.Label1 = "Hello"
End Sub

This is what I was trying to do in the vb.net app with no
luck. Any suggestions greatly appreciated. And thanks
again for your reply.

Steve
-----Original Message-----
Steve,

Do you mean this?

\\\
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim myfiller As New filler
myfiller.sayhello(Me.Label1)
End Sub
///end form
\\\begin class
Public Class filler
Public Sub sayhello(ByVal meControl As Control)
meControl.Text = "hello from class object"
End Sub
End Class
///

Cor

"Steve" <an*******@discussions.microsoft.com>
Hello,

If I instantiate a class object from a form I would like
to be able to write to a label on the calling form
something like

"hello from class object"

from within a subroutine inside the class object. Is this possible?

I tried the following in the class object

Public Class MyClass
Dim frm As New Form1

Sub RunProcess()
...
frm.lbl1.Text = "hello from class object"
Do While ...
... takes about 5 minutes to run loop
Loop
...
End sub
End Class

If it is possible to write to a label on the calling form from within the subroutine in my class object, may I ask
what the syntax looks like?

Thanks,
Steve

.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
16
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation....
10
by: Drakier Dominaeus | last post by:
This is my first time posting here, so please forgive me if I do anything incorrectly. I've been learning C# and working with different things and decided I wanted to get into Multi-Threading....
6
by: Claus Holm | last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather than making the menuitems public, I'd go for a public method in the parent form to do the change, but when I call the...
0
by: Benjamin Bittner | last post by:
Hallo NG, ive searched a lot in some google groups, and found many threads, but nothing that helped me. Here is the scenario: I have an aspx page which loads a user control in page.onInit like...
4
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
0
by: enrmpaga | last post by:
i'm using asp.c# to validate form and e-mail the results to my inbox but keep getting this error message: Compiler Error Message: CS0117: 'System.Web.UI.HtmlControls.HtmlForm' does not contain a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.