-1

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.

user3094822
  • 5
  • 1
  • 1
  • 3
  • 2
    what does "zeroise" mean? Does the the array contain the checkboxes or the checkstate? – Ňɏssa Pøngjǣrdenlarp Jan 23 '14 at 15:54
  • By "zeroise", I mean that i fill the array with zeros. This array contains only "1" if the boxes are checked, "0" if not. – user3094822 Jan 23 '14 at 16:01
  • when you create the array it is already "zeroised". are you looking for a way to re-zeroise it? the nature of the title sounds like you dont know how to create a procedure – Ňɏssa Pøngjǣrdenlarp Jan 23 '14 at 16:46
  • I didn't know that my array was filled with zero since it was created, sorry. I'm a great beginner at vb.net. I know how to create a procedure, but didn't know how to launch it immediatly with the first form, without being user-triggered. I'm grateful for your help, and sorry again for my low level. – user3094822 Jan 24 '14 at 09:11

2 Answers2

1

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

Maximilian Riegler
  • 22,720
  • 4
  • 62
  • 71
0

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

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • It works well. THANK YOU very much for this answer, and thanks again for having taken a piece of your time to help me. Have a good day. – user3094822 Jan 23 '14 at 16:29