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

Modules

Hi,

I just wanted a hand on using modules. I have just
managed to create a custom smooth progress bar control
and i wanted to know if it is possible to insert the code
in a module so it can be called from any of my forms.
what i am confused on is the syntax i have to use in the
module. here is my code i will need to reuse for each
onclick event throughout my appliaction:

Me.SmoothProgressBar1.Value = 100
Me.SmoothProgressBar2.Value = 0

Me.Timer1.Interval = 1
Me.Timer1.Enabled = True

i also have to add code for the tick event for each timer
i place on the forms that use the PBar. here is the code
for that:

If (Me.SmoothProgressBar1.Value > 0) Then
Me.SmoothProgressBar1.Value -= 1
Me.SmoothProgressBar2.Value += 1
Else
Me.Timer1.Enabled = False
End If

Can anyone help me with what i need to write in my
module? and what code i need to call this for eac onclick
event.

Im new to all this and would appreciate any help
Nov 20 '05 #1
8 1369
"Alexia" <an*******@discussions.microsoft.com> schrieb
I just wanted a hand on using modules. I have just
managed to create a custom smooth progress bar control
and i wanted to know if it is possible to insert the code
in a module so it can be called from any of my forms.
what i am confused on is the syntax i have to use in the
module. here is my code i will need to reuse for each
onclick event throughout my appliaction:


Why do you want to use a Module? A control is a class directly or indirectly
inherited from System.Windows.Forms.Control:

Class MyControl
Inherits Controls

'...
End Class

To add the control to a Form, execute the following code within the Form:

dim c as mycontrol

c = New MyControl 'creates the control
Me.Controls.Add(c) 'adds it to the Form
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #2
Im not sure on what the best approach was. I was told to
use a module by my friend.
All i want to achieve is to wright the code i stated
below in one place so i dont have to keep re-writing it
througout my application.
What is the best approach to achieve this??
-----Original Message-----
"Alexia" <an*******@discussions.microsoft.com> schrieb
I just wanted a hand on using modules. I have just
managed to create a custom smooth progress bar control
and i wanted to know if it is possible to insert the code in a module so it can be called from any of my forms.
what i am confused on is the syntax i have to use in the module. here is my code i will need to reuse for each
onclick event throughout my appliaction:
Why do you want to use a Module? A control is a class

directly or indirectlyinherited from System.Windows.Forms.Control:

Class MyControl
Inherits Controls

'...
End Class

To add the control to a Form, execute the following code within the Form:
dim c as mycontrol

c = New MyControl 'creates the control
Me.Controls.Add(c) 'adds it to the Form
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

.

Nov 20 '05 #3
Alexia,

What Armin is saying is that once you put the code in your control it will
"go along" with the control every time you drag and drop it on a form.
There is no need to separate out the code in to a module.

Dan


"Armin Zingler" <az*******@freenet.de> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...
"Alexia" <an*******@discussions.microsoft.com> schrieb
I just wanted a hand on using modules. I have just
managed to create a custom smooth progress bar control
and i wanted to know if it is possible to insert the code
in a module so it can be called from any of my forms.
what i am confused on is the syntax i have to use in the
module. here is my code i will need to reuse for each
onclick event throughout my appliaction:
Why do you want to use a Module? A control is a class directly or

indirectly inherited from System.Windows.Forms.Control:

Class MyControl
Inherits Controls

'...
End Class

To add the control to a Form, execute the following code within the Form:

dim c as mycontrol

c = New MyControl 'creates the control
Me.Controls.Add(c) 'adds it to the Form
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #4
"Alexia" <an*******@discussions.microsoft.com> schrieb
Im not sure on what the best approach was. I was told to
use a module by my friend.
All i want to achieve is to wright the code i stated
below in one place so i dont have to keep re-writing it
througout my application.
What is the best approach to achieve this??

I read it several times now, but I still don't get it. (it's 00:45 AM here
;-)

Is the code you posted the event handler for OnClick of the progressbar? Why
do you use two Progressbars? Is the Timer part of the Progressbar and does
it always exist for each progressbar?

Could you please describe the circumstances once again?
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html
Nov 20 '05 #5
Hi Armin,

the code i have posted is part of the onclick event for a
button that starts the progress bar. The timer is also a
part of the progress bar as this is a custom built
control. The timer always exists for every proress bar.

There shoulkd only be one progress bar in that code i gave.

any further advise u can give?? the code u gave me....
where do i write this?? i tried to copy and paste it into
my code window but it didnt seem to like it. Could u plz
explain what it is doin? sorry, im a real beginner to all
this.

--------------------------------------------

I read it several times now, but I still don't get it. (it's 00:45 AM here;-)

Is the code you posted the event handler for OnClick of the progressbar? Whydo you use two Progressbars? Is the Timer part of the Progressbar and doesit always exist for each progressbar?

Could you please describe the circumstances once again?
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html
.

Nov 20 '05 #6
"Alexia" <an*******@discussions.microsoft.com> schrieb
the code i have posted is part of the onclick event for a
button that starts the progress bar. The timer is also a
part of the progress bar as this is a custom built
control. The timer always exists for every proress bar.

There shoulkd only be one progress bar in that code i gave.

any further advise u can give?? the code u gave me....
where do i write this?? i tried to copy and paste it into
my code window but it didnt seem to like it. Could u plz
explain what it is doin? sorry, im a real beginner to all
this.


No problem, we were all beginners. :-)

You wrote: "I have just managed to create a custom smooth progress bar
control". That's why I assumed that you've already created your own class
that is directly or inderectly derived from System.Windows.Forms.Control.
The class System.Windows.Forms.Control is the base class for all controls.
Labels, Textboxes and so on are all derived from the Control class.

How to create your own controls:
http://msdn.microsoft.com/library/en...mscontrols.asp

About OOP, especially the sub topic "Inheritance":
http://msdn.microsoft.com/library/en...ithObjects.asp
These are two progress bars:
Me.SmoothProgressBar1.Value = 100
Me.SmoothProgressBar2.Value = 0
What is the type of SmoothProgressBar1 and SmoothProgressBar2? Didn't you
create them on your own?
The code I gave you is the base structure of a class. It is usually in a
separate file. Where did you paste the code?

The following lines
dim c as mycontrol

c = New MyControl 'creates the control
Me.Controls.Add(c) 'adds it to the Form

can be pasted in the Load event of the Form or in the constructor. The
constructor is Sub New in the "Windows Forms Designer generated code"
region. After calling InitializeComponents, the code can be executed. You
can also put it in a sub outside the constructor and call it in the
constructor to avoid opening the region every time you want to add code to
the constructor. Example:

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated Code "

Public Sub New()
MyBase.New()

InitializeComponent()

MyNew
End Sub
'.....
#end region

private Sub MyNew
dim c as mycontrol

c = New MyControl 'creates the control
Me.Controls.Add(c) 'adds it to the Form
end sub

'......
End Class
I hope this helps because I still didn't fully understand the structure of
your current project. Please ask again if something's not clear.

--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #7
Thx for your help Armin,

As you probably guessed, i didnt write the controls on my
own. I was directed to a website that had all the code and
instructions so i am not to sure on how it all works. I
got the code from:

http://support.microsoft.com/default.aspx?scid=kb;EN-
US;Q323088

I pasted the code into the form load event but it didnt
like it for some reason. Im about to leave work now so i
will try again when i get home. I will let u know about
the outcome.
Thx again for your help. :o)

-----Original Message-----
"Alexia" <an*******@discussions.microsoft.com> schrieb
the code i have posted is part of the onclick event for a button that starts the progress bar. The timer is also a
part of the progress bar as this is a custom built
control. The timer always exists for every proress bar.

There shoulkd only be one progress bar in that code i gave.
any further advise u can give?? the code u gave me....
where do i write this?? i tried to copy and paste it into my code window but it didnt seem to like it. Could u plz
explain what it is doin? sorry, im a real beginner to all this.
No problem, we were all beginners. :-)

You wrote: "I have just managed to create a custom smooth

progress barcontrol". That's why I assumed that you've already created your own classthat is directly or inderectly derived from System.Windows.Forms.Control.The class System.Windows.Forms.Control is the base class for all controls.Labels, Textboxes and so on are all derived from the Control class.
How to create your own controls:
http://msdn.microsoft.com/library/en- us/cpguide/html/cpconcreatingwinformscontrols.asp
About OOP, especially the sub topic "Inheritance":
http://msdn.microsoft.com/library/en- us/vbcn7/html/vbconProgrammingWithObjects.asp

These are two progress bars:
Me.SmoothProgressBar1.Value = 100
Me.SmoothProgressBar2.Value = 0
What is the type of SmoothProgressBar1 and SmoothProgressBar2? Didn't youcreate them on your own?
The code I gave you is the base structure of a class. It is usually in aseparate file. Where did you paste the code?

The following lines
dim c as mycontrol

c = New MyControl 'creates the control
Me.Controls.Add(c) 'adds it to the Form

can be pasted in the Load event of the Form or in the constructor. Theconstructor is Sub New in the "Windows Forms Designer generated code"region. After calling InitializeComponents, the code can be executed. Youcan also put it in a sub outside the constructor and call it in theconstructor to avoid opening the region every time you want to add code tothe constructor. Example:

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated Code "

Public Sub New()
MyBase.New()

InitializeComponent()

MyNew
End Sub
'.....
#end region

private Sub MyNew
dim c as mycontrol

c = New MyControl 'creates the control
Me.Controls.Add(c) 'adds it to the Form
end sub

'......
End Class
I hope this helps because I still didn't fully understand the structure ofyour current project. Please ask again if something's not clear.
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

.

Nov 20 '05 #8
"Alexia" <an*******@discussions.microsoft.com> schrieb
Thx for your help Armin,

As you probably guessed, i didnt write the controls on my
own. I was directed to a website that had all the code and
instructions so i am not to sure on how it all works. I
got the code from:

http://support.microsoft.com/default.aspx?scid=kb;EN-
US;Q323088

I pasted the code into the form load event but it didnt
like it for some reason. Im about to leave work now so i
will try again when i get home. I will let u know about
the outcome.
Thx again for your help. :o)

Didn't you follow the steps described in the mentioned site? I can not
describe it better. :-)
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #9

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

Similar topics

2
by: Dave | last post by:
Hi Everyone, I am trying to import a package and then loop through the modules inside the package, but I'm running to a problem. Basically: ----- I have a package called...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
7
by: Jorgen Grahn | last post by:
I have a set of tests in different modules: test_foo.py, test_bar.py and so on. All of these use the simplest possible internal layout: a number of classes containing test*() methods, and the good...
4
by: Misto . | last post by:
Hi folks! Short: There is a way to dumplicate a module ? I tried copy.deepcopy(module) but hangs with an error (also with standard modules ).. The only solution that I have by now is...
2
by: James Buchanan | last post by:
Hi group, I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I have problems with make. configure runs fine and creates the makefile, but right at the end ends with an error...
7
by: Lauren Quantrell | last post by:
At running the risk of asking how big is too big... Is there a rule of thumb or a best practice that says I may have too many modules? I currently have a Access2K app with about 30 code modules,...
13
by: Robin Haswell | last post by:
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules...
173
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them (avoiding importing problems and Consicing code and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...

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.