Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write an Init() that works? 1

Status
Not open for further replies.

rshearin

Programmer
Jan 16, 2007
5
US
I posted this to the wrong forum originally and it was suggested that I repost it here.

OK, by now you've already figured out that I am not a VBA programmer. However, I need to write one very basic form. I seem to have most of it working well but I can not figure out how to properly write an Init() and/or get it to run when I open the form that I am creating. I am using Visual Basic 2005 Express and clicking on Debug -> Start Debugging to get it to run. Here's the basic code with some of the meat taken out since it isn't related to the problem.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate(" Button1.Hide()
Button2.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub

Private Sub Init()
MsgBox("help me")
End Sub

End Class

How do I write Init() so that when I open the form, it gets called immediately?

Thanks in advance!
 
try using/handling the load event or use in the constructor:

Load event :

Code:
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        MsgBox("Help me") 'or Call Init()

        End Sub


or constructor:

Code:
        Public Sub New()

            ' This call is required by the Windows Form Designer.
            InitializeComponent()

            ' Add any initialization after the InitializeComponent() call.
            MsgBox("Help me") 'or Call Init()
        End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top