• Advertisement

Archived

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

Procedures In VB6

This topic is 5269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
for the line break:
lblSomeLabel.caption = "some text" & VBNewLine & "Some other text"

hope that helps

Matt

Share this post


Link to post
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 form
Public Sub InitControls()
Label1.Caption = "Some text"
End Sub

''In a module
Public Sub Main()

Dim frm As New Form1

frm.InitControls
frm.Show

End Sub

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

  • Advertisement