473,554 Members | 3,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In my module I'm able to read/write to form objects, but I can't modify StatusBar.Text, why?

Hi Gang,
I've had this happen with a couple of controls now, but my patience has worn
thin. Can somebody tell me why I can read/write to most objects on my form
from my module, but not when working with StatusBar.Text?
Thanks in Advance,
Christian Blackburn

My Code:
Public Class frmMain

Friend WithEvents StatusBar As System.Windows. Forms.StatusBar

'StatusBar

'

Me.StatusBar.Lo cation = New System.Drawing. Point(0, 291)

Me.StatusBar.Na me = "StatusBar"

Me.StatusBar.Si ze = New System.Drawing. Size(240, 22)

Me.StatusBar.Ta bIndex = 25

Me.StatusBar = New System.Windows. Forms.StatusBar

'frmMain

'

Me.Controls.Add (Me.StatusBar)

Private Sub mnuWriteToStatu sBar_Click(ByVa l sender As System.Object, ByVal e
As System.EventArg s) Handles mnuWriteToStatu sBar.Click

StatusBar.Text = "I'm from the form's code"

End Sub

Private Sub mnuAddToStatusB arFromModule_Cl ick(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles mnuAddToStatusB arFromModule.Cl ick

WriteToStatusBa r()

End Sub

End Class

Module App

'Creates an object reference to our application's form, because otherwise we
can't work with it (lame-o)

Public objfrmMain As New frmMain

Public Sub WriteToStatusBa r()

objfrmMain.Stat usBar.Text = "I'm from the module."

End Sub

End Module


Nov 20 '05 #1
9 2073
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Gang,
I've had this happen with a couple of controls now, but my patience
has worn thin. Can somebody tell me why I can read/write to most
objects on my form from my module, but not when working with
StatusBar.Text? Thanks in Advance,
Christian Blackburn

My Code:
Public Class frmMain

Friend WithEvents StatusBar As System.Windows. Forms.StatusBar

'StatusBar

'

Me.StatusBar.Lo cation = New System.Drawing. Point(0, 291)

Me.StatusBar.Na me = "StatusBar"

Me.StatusBar.Si ze = New System.Drawing. Size(240, 22)

Me.StatusBar.Ta bIndex = 25

Me.StatusBar = New System.Windows. Forms.StatusBar

'frmMain

'

Me.Controls.Add (Me.StatusBar)

Private Sub mnuWriteToStatu sBar_Click(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles mnuWriteToStatu sBar.Click

StatusBar.Text = "I'm from the form's code"

End Sub

Private Sub mnuAddToStatusB arFromModule_Cl ick(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
mnuAddToStatusB arFromModule.Cl ick

WriteToStatusBa r()

End Sub

End Class

Module App

'Creates an object reference to our application's form, because
otherwise we can't work with it (lame-o)

Public objfrmMain As New frmMain

Public Sub WriteToStatusBa r()

objfrmMain.Stat usBar.Text = "I'm from the module."

End Sub

End Module

Is the variable declared in the module (objfrmMain) holding the reference to
the form the same object that you are showing? Means: Do you call
objfrmMain.Show
anywhere? If not, you are creating two instances of the form and changing
the statusbar text of the invisible form.
--
Armin

Nov 20 '05 #2
> Is the variable declared in the module (objfrmMain) holding the reference
to
the form the same object that you are showing? Means: Do you call
objfrmMain.Show
anywhere? If not, you are creating two instances of the form and changing
the statusbar text of the invisible form.
--
Armin


Hi Armin,
You would have to be absolutely correct. It seems perfectly logical that I
would be modifying the invisible copy. That's really funny though I tried
to tell my VB teacher that what he was doing didn't make much sense.
However he said it was correct and so I just did what he said and most of
the time that works :). So how should I go about accessing my form's
properties/methods from a module when the form is my Sub_Main? He's a Fox
Pro programmer mainly and really doesn't seem to know VB that well. I can
tell, because I've been programming in VB5-6 (and a little bit of VB1 for
Dos) for 5 years now.
Thanks a Zillion,
Christian Blackburn

Nov 20 '05 #3
Hi Armin,
I take that back read/writing the properties didn't work at all. The reason
I thought it was working is because I created a collection of picture boxes
in my module that was a collection of the form's picture boxes. Obviously
read/writing to the collection worked fine, because I was working with the
correct set of picture boxes.
You Da Man,
Christian

"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> wrote in message
news:Of******** *****@TK2MSFTNG P12.phx.gbl...
Is the variable declared in the module (objfrmMain) holding the reference
to
the form the same object that you are showing? Means: Do you call
objfrmMain.Show
anywhere? If not, you are creating two instances of the form and
changing the statusbar text of the invisible form.
--
Armin


Hi Armin,
You would have to be absolutely correct. It seems perfectly logical that

I would be modifying the invisible copy. That's really funny though I tried
to tell my VB teacher that what he was doing didn't make much sense.
However he said it was correct and so I just did what he said and most of
the time that works :). So how should I go about accessing my form's
properties/methods from a module when the form is my Sub_Main? He's a Fox
Pro programmer mainly and really doesn't seem to know VB that well. I can
tell, because I've been programming in VB5-6 (and a little bit of VB1 for
Dos) for 5 years now.
Thanks a Zillion,
Christian Blackburn

Nov 20 '05 #4
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Armin,
I take that back read/writing the properties didn't work at all. The
reason I thought it was working is because I created a collection of
picture boxes in my module that was a collection of the form's
picture boxes. Obviously read/writing to the collection worked fine,
because I was working with the correct set of picture boxes.
You Da Man,
Christian


Ummm... Problem solved now?

If not: ;-)
Why don't you put the code in the form?
--
Armin
Nov 20 '05 #5
Hi Armin,

"Armin Zingler" <az*******@free net.de> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Armin,
I take that back read/writing the properties didn't work at all. The
reason I thought it was working is because I created a collection of
picture boxes in my module that was a collection of the form's
picture boxes. Obviously read/writing to the collection worked fine,
because I was working with the correct set of picture boxes.
You Da Man,
Christian Ummm... Problem solved now?


Not exactly I would still like to be able to work with my form from a module
that seems like normal VB functionality to me. I like to keep all my events
in the Form and procedures and functions in one or more modules. It's just
neater that way since I tend to write a plethora of procedures and functions
:).

If not: ;-)
Why don't you put the code in the form?
I agree that this is an easy work around, but surely there must be a way to
reference the one and only form in my project from my one and only module
(currently anyways)?

Thanks Again,
Christian Blackburn

--
Armin

Nov 20 '05 #6
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Armin,

"Armin Zingler" <az*******@free net.de> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Armin,
I take that back read/writing the properties didn't work at all.
The reason I thought it was working is because I created a
collection of picture boxes in my module that was a collection of
the form's picture boxes. Obviously read/writing to the
collection worked fine, because I was working with the correct
set of picture boxes. You Da Man,
Christian

Ummm... Problem solved now?


Not exactly I would still like to be able to work with my form from a
module that seems like normal VB functionality to me. I like to keep
all my events in the Form and procedures and functions in one or more
modules. It's just neater that way since I tend to write a plethora
of procedures and functions :).


If you are collecting functions related to a Form in a Module, it's much
more neater when you put it into the From. :)
If not: ;-)
Why don't you put the code in the form?


I agree that this is an easy work around, but surely there must be a
way to reference the one and only form in my project from my one and
only module (currently anyways)?


Pass the form to the module, or show the Form declared and created in the
module _instead_ of the form instance that you are showing currently.
--
Armin

Nov 20 '05 #7
Hi Armin,
If you are collecting functions related to a Form in a Module, it's much
more neater when you put it into the From. :)
Well now we are getting into matters of personal preference :). I just
don't like to have all those functions and procedures in one place I'm sure
some people, if not most, do. I'll be the first to agree that it requires a
bit more syntax to make it happen, but I suppose not if you use "Imports"
which I'll have to look into.
If not: ;-)
Why don't you put the code in the form?


I agree that this is an easy work around, but surely there must be a
way to reference the one and only form in my project from my one and
only module (currently anyways)?


Pass the form to the module, or show the Form declared and created in the
module _instead_ of the form instance that you are showing currently.


Okay so here's what wound up working:

Form_Load Code:
'Tells the module what FOrm objfrmMain represents

objfrmMain = Me
Module Declaration:

'Creates an object reference to our application's form, because otherwise we
can't work with it (lame-o)

Public objfrmMain As frmMain

Armin


Thanks for helping me get that working,
Christian Blackburn
Nov 20 '05 #8
Hi Armin,
Since it is correct that working with forms from forms requires less syntax.
I guess I will have to get used to doing that. I'll try it out on this
project for kicks and giggles. Who knows maybe I'll like it.
Cheers,
Christian Blackburn
"Armin Zingler" <az*******@free net.de> wrote in message
news:uE******** *****@tk2msftng p13.phx.gbl...
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Armin,

"Armin Zingler" <az*******@free net.de> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
> Hi Armin,
> I take that back read/writing the properties didn't work at all.
> The reason I thought it was working is because I created a
> collection of picture boxes in my module that was a collection of
> the form's picture boxes. Obviously read/writing to the
> collection worked fine, because I was working with the correct
> set of picture boxes. You Da Man,
> Christian
Ummm... Problem solved now?


Not exactly I would still like to be able to work with my form from a
module that seems like normal VB functionality to me. I like to keep
all my events in the Form and procedures and functions in one or more
modules. It's just neater that way since I tend to write a plethora
of procedures and functions :).


If you are collecting functions related to a Form in a Module, it's much
more neater when you put it into the From. :)
If not: ;-)
Why don't you put the code in the form?


I agree that this is an easy work around, but surely there must be a
way to reference the one and only form in my project from my one and
only module (currently anyways)?


Pass the form to the module, or show the Form declared and created in the
module _instead_ of the form instance that you are showing currently.
--
Armin

Nov 20 '05 #9
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Armin,
Since it is correct that working with forms from forms requires less
syntax. I guess I will have to get used to doing that. I'll try it
out on this project for kicks and giggles. Who knows maybe I'll like
it. Cheers,
Christian Blackburn


Let us know. :-)
--
Armin

Nov 20 '05 #10

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

Similar topics

1
2586
by: Peter Åstrand | last post by:
There's a new PEP available: PEP 324: popen5 - New POSIX process module A copy is included below. Comments are appreciated. ---- PEP: 324 Title: popen5 - New POSIX process module
1
4156
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) ...
25
7732
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30 minutes with Python 3 times a week since, have 14 years of computing experience, 8 years in mathematical computing and 4 years in unix admin and perl, i...
3
5660
by: JimF | last post by:
I need to scan a couple of hundred databases in several directories to locate all code that uses a particular function, but cannot figure out how to read the Form or Module text itself. I am able to locate, then connect to the databases, and have figured out how to get the Form and Module names easy enough using the documents collection of...
8
18627
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window available in the same form for users to enter commands and display outputs if some prefer to use character based user interface. I would like to implement...
11
3086
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend a hand? import regsub
9
2337
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice = CDec(txbInv.Text) Wage = CDec(txbTotWage.Text)
9
1400
by: jdlists | last post by:
I have inheirted some existing code, that i will explain in a moment, have needed to extend and ultimately should be able to run in threads. I've done a bunch of work with python but very little with threads and am looking for some pointers on how to implement, and if the lower level modules/objects need to be rewritten to use threading.local...
8
1582
by: Derek Martin | last post by:
I'd like to know if it's possible to code something in Python which would be equivalent to the following C: ---- debug.c ---- #include <stdio.h> bool DEBUG;
0
7507
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6127
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5424
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5143
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1115
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
825
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.