Question

I have a very basic question on vb.NET, so basic that I didn't find any answer elsewhere. I've written with VB express a code that is a simple form proposing various choices through checkboxes. These choices have to be registered in an array, which I convert later into a textfile to be Perl-processed. I'm searching a way to zeroise this big array with loops before use, but in fact I don't know how to execute instructions which wouldn't be triggered by events in my main form. The frame looks like that :

Public Class Form1
'Variables declaration...

'Several boxes like that :
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
'Instructions...
End Sub

End Class

To launch this application, I simply click on the associated .exe file. Basically, my question is : is there a way to execute instructions that wouldn't be launched by an user event, but immediatly launched when the main Form1 is shown ? Sorry for being retarded, and thank you in advance if you can help me.

Was it helpful?

Solution 2

The Form will raise a Shown event when it is shown simply handle that:

Private Sub Form_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Shown
    'Instructions...
End Sub

It can be better to do initialisation in the constructor right after the Winforms designer adds the comment: 'Add any initialization after the InitializeComponent() call

OTHER TIPS

The Form.Load event for instance gets launched as soon as the form is about to be shown :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top