#### Archived

This topic is now archived and is closed to further replies.

# Procedures In VB6

## Recommended Posts

In my VB6 program, I''m setting some of the variables of objects on a form using a BAS module procedure right before displaying the form. Would it make more sense to associate this procedure with the form itself? Would this just be done using a public sub and calling it using the form name (form has not yet been made visible at this point)? Also, on a side note, how do you add a line break to a text label?

##### Share on other sites
for the line break:
lblSomeLabel.caption = "some text" & VBNewLine & "Some other text"

hope that helps

Matt

##### Share on other sites
There''s a couple of options. You can do what you stated, you can just have the form set itself up in the Form_Load event:
Private Sub Form_Load()    Label1.Caption = "Some text"End Sub

you can also put the code in a procedure in the form and call it from outside:
''In the formPublic Sub InitControls()    Label1.Caption = "Some text"End Sub''In a modulePublic Sub Main()    Dim frm As New Form1        frm.InitControls    frm.Show    End Sub

##### Share on other sites
Thanks a lot. The line break thing makes sense. From how it looks, I''m probably going to transfer procedures form a module into forms because it just makes more sense. Thanks again.

• ### Forum Statistics

• Total Topics
628316
• Total Posts
2982032

• 9
• 9
• 13
• 11
• 14