vb4: bas modules and form modules 
Author Message
 vb4: bas modules and form modules

Hi,

I am new to VB programming.  I created an app that has a form, I ended up
writing  new procedures into my form module. Recently I read somewhere
about placing my code into a standard module (*.bas) instead.  Currently,
to change the text in my textbox I have text1.text = "David".  If I move my
procedure to a standard module (*.bas) will I have to reference the form
where control resides (form1.text1.text).    In this app I am only using 1
form anyway.

I am also doing data entry.  I add a textbox and in front of it I added a
label:

FIRST NAME:  _______________

My textbox has a border style of 1-fixed single and appearance is 3d.  I
wanted my label to be border style: 0.  However, the horizontal alignment
of the 2 controls is a little off.  If I change my label to 1 in the border
style it will work.  But I would rather not do this.  I also have ms-access
and I don't have this problem when I add controls on a form.

Thanks for any info,

David :)
chapa at spec dot com



Sat, 23 Sep 2000 03:00:00 GMT  
 vb4: bas modules and form modules



Quote:
> Hi,

> I am new to VB programming.  I created an app that has a form, I ended up
> writing  new procedures into my form module. Recently I read somewhere
> about placing my code into a standard module (*.bas) instead.  Currently,
> to change the text in my textbox I have text1.text = "David".  If I move
my
> procedure to a standard module (*.bas) will I have to reference the form
> where control resides (form1.text1.text).    In this app I am only using
1
> form anyway.

> I am also doing data entry.  I add a textbox and in front of it I added a
> label:

> FIRST NAME:  _______________

> My textbox has a border style of 1-fixed single and appearance is 3d.  I
> wanted my label to be border style: 0.  However, the horizontal alignment
> of the 2 controls is a little off.  If I change my label to 1 in the
border
> style it will work.  But I would rather not do this.  I also have
ms-access
> and I don't have this problem when I add controls on a form.

> Thanks for any info,

> David :)
> chapa at spec dot com

In answer to your first question, when you refer to an object in a form
from a module, even if you only have one form, then you must tell the
module what form the object is in.  This is done, as you stated, by the
syntax:   frmMain.txtFirstName.text

In answer to the second question, forms in VB, have a grid.  When you add
or move an object it automatically 'snaps' to this grid.  To sort out your
problem, you will have to turn  off this snapping to grid.  This is done
by, clicking the menuitem, 'Tools', then 'Options'.  Select the tab
'Enviroment' (should already be selected), then untick the checkbox 'Align
Controls to Grid'.  This should let you move your objects around without
the limit of the grid.

--

-------------------
Dan Clarke

"Imagination is more important than knowledge."
   -- Albert Einstein



Sun, 24 Sep 2000 03:00:00 GMT  
 vb4: bas modules and form modules



Quote:
>Recently I read somewhere
>about placing my code into a standard module (*.bas) instead.

Keep the code, that is related to a form, strictly in that form. Only general
procedures and variables, that may be shared by multiple forms, should be
placed in BAS modules.

DoDi



Sun, 24 Sep 2000 03:00:00 GMT  
 vb4: bas modules and form modules

1.  You can pass a form as a parameter to your procedure located in a
module.  You can then reference the original form using the parameter name.

    Public Sub FooBar(SubjectForm As Form)
    ' Your code here
    SubjectForm.Text1.Text = "David"
    End Sub

2.  I manually realign my labels by setting the labels' Top property to the
TextBox.Top + 45.  This assumes a ScaleMode of Twip.

--
John Tabor

http://userweb.idsonline.com/jtabor
Note:  Anti-spamming suffix of ".nospam" added to header.
-------------------------------------

Quote:



>> Hi,

>> If I move my
>> procedure to a standard module (*.bas) will I have to reference the form
>> where control resides (form1.text1.text).    In this app I am only using
1
>> form anyway.
>> ...
>> My textbox has a border style of 1-fixed single and appearance is 3d.  I
>> wanted my label to be border style: 0.  However, the horizontal alignment
>> of the 2 controls is a little off.  If I change my label to 1 in the
>border
>> style it will work.  But I would rather not do this.  I also have
>ms-access
>> and I don't have this problem when I add controls on a form.



Fri, 29 Sep 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Accessing Form Controls From a .BAS module

2. Please help: Updating form controls from a separate BAS module

3. Please help: Updating form controls from a separate BAS module

4. Updating form controls using outside BAS modules

5. Adding a form to project creates module(*.bas)

6. Adding a form to project creates module(*.bas)

7. Communication Between Form/Bas Module

8. Can you pass form to a module (*.bas)??

9. Can you pass form to a module (*.bas)??

10. Can you pass form to a module (*.bas)??

11. Can you pass form to a module (*.bas)??

12. Modules, Modules, Modules

 

 
Powered by phpBB® Forum Software