473,324 Members | 2,196 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,324 software developers and data experts.

Writing to a label.text on form from within a module

RD
Form1 calls a sub that is public in module1.

How do you write a value to a text property from with this sub?

Eg

Module myModule
sub mysub()
'From here how do I write to the label1.text that is on the
currently open form (form1) that called this sub
end sub
end module

Thanks for any help,
Bob
Nov 21 '05 #1
5 2263
try this

Module myModule
sub mysub()
form1.label1.text = "Hello World"
end sub
end module

"RD" <no****@nospam.net> wrote in message
news:uQ**************@TK2MSFTNGP14.phx.gbl...
Form1 calls a sub that is public in module1.

How do you write a value to a text property from with this sub?

Eg

Module myModule
sub mysub()
'From here how do I write to the label1.text that is on the
currently open form (form1) that called this sub
end sub
end module

Thanks for any help,
Bob

Nov 21 '05 #2
RD
Thanks,
But this does not work.
form1 is not recognized in the IDE (it shows a wavy underline) and it won't
compile.
I get reference to a non-shared member requires object reference error in
task list.

Thanks for your help.

"Scott Gunn" <sc***@thebigspider.co.uk> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
try this

Module myModule
sub mysub()
form1.label1.text = "Hello World"
end sub
end module

"RD" <no****@nospam.net> wrote in message
news:uQ**************@TK2MSFTNGP14.phx.gbl...
Form1 calls a sub that is public in module1.

How do you write a value to a text property from with this sub?

Eg

Module myModule
sub mysub()
'From here how do I write to the label1.text that is on the
currently open form (form1) that called this sub
end sub
end module

Thanks for any help,
Bob


Nov 21 '05 #3
If the sub method really should belong in the form class, add it to the
class.

If it should be a public method, then...
Turn the sub into a function that returns the desired caption.
Instead of a Sub, use a function in the module:
Function myfunction() as String
Return "Hello World"
End Function

Calling from Form:
label1.text = myfunction()

Or

Provide an appropriate method on your form class to update the caption.
Pass in an instance to the form to the sub, and have the sub call the
method.
Form:
Public Sub SetLabelCaption(Value as String)
label1.text = Value
End Sub

Sub:
Sub MySub(FormInstance as Form1)
...
FormInstance.SetLabelCaption ("Hello World")
End sub

Calling Sub from Form:
MySub(Me)

Or, any number of other ways. Just make sure that you provide a way to
uniquely identify the particular instance of the Form1 in question, and be
aware of potential threading issues.

Gerald

"RD" <no****@nospam.net> wrote in message
news:uQ**************@TK2MSFTNGP14.phx.gbl...
Form1 calls a sub that is public in module1.

How do you write a value to a text property from with this sub?

Eg

Module myModule
sub mysub()
'From here how do I write to the label1.text that is on the
currently open form (form1) that called this sub
end sub
end module

Thanks for any help,
Bob

Nov 21 '05 #4
"RD" <no****@nospam.net> schrieb:
Form1 calls a sub that is public in module1.

How do you write a value to a text property from with this sub?

Eg

Module myModule
\\\
Public Sub SetLabelText(ByVal Label As Label)
Label.Text = ...
End Sub
///
end module


Usage:

\\\
MyModule.SetLabelText(Me.Label1)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5
RD,

You would not want to do that. It is against everything that is OOP.

You can do in your form
\\\
me.label.text = MyOwnClass.Hello
///
And than you have in myownclass
\\\
class MyOwnClass
Friend Shared ReadOnly Property hello() as String
Get
Return "Hello"
End Get
End Property
///

This just as idea what is in this form crasy and I hope it gives you that?

Cor

"RD" <no****@nospam.net>
Form1 calls a sub that is public in module1.

How do you write a value to a text property from with this sub?

Eg

Module myModule
sub mysub()
'From here how do I write to the label1.text that is on the
currently open form (form1) that called this sub
end sub
end module

Thanks for any help,
Bob

Nov 21 '05 #6

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

Similar topics

7
by: Mike Casey | last post by:
Hello all, I have ASP.NET label controls tied to a datasource (so text will vary in length depending on the record). In IE everything looks great--text is wrapped if needed. In Netscape and...
1
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the...
3
by: Neil Wallace | last post by:
Hi, This is an odd one. I've been struggling to get "double click" to work well for my controls. The same event handler works perfectly for buttons, but not for labels. Can anyone tell me...
5
by: Luis Ramos | last post by:
Hello, How do i change a label in another form from another one? in vb6 i use to do this: form1: private sub label1_change() form2.label1.caption="hgghjghjg" ' and the label in form2 is...
7
by: Hexman | last post by:
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...
10
by: cj | last post by:
I'm having a problem writing an insert command to work with a datatable. I've looked at what the sqldataadapter creates and created my insert command to look the same. I have:...
8
by: Arpan | last post by:
Consider the following code snippet (my main intention is to display the current time in a Label control as & when this ASPX page is accessed/refreshed): <script runat="server"> Class Clock...
0
by: mcc99 | last post by:
Amazing, I surfed around to find a simple utility that could list files recursively from a given top folder down through it, writing out the path and filename in simple \path\file_name form, without...
11
by: Peter Larsen [] | last post by:
Hi, I have two questions related to the Label control. How do i prevent the label from expand the canvas into 2 lines (word wrap) ?? At the moment i set AutoSize to false (to prevent the word...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.