Archived

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

gamechampionx

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