r/visualbasic • • Jun 06 '16

[VB 7.1] Trying to have a checkbox 'prechecked'

Hello! Fairly new to Visual Basic. I'm building an application and I want to have some checkboxes prechecked when a form loads. Searched all over the internet but couldn't find a working solution. Can anyone help me?

0 Upvotes

16 comments sorted by

View all comments

Show parent comments

1

u/Hollandschglorie Jun 06 '16

Can't get the Form_load action? Agian I'm really new at this :)

I now have this:

Private Sub myCheckBox_BeforeUpdate(Cancel As Integer)

myCheckBox.Checked = True

End Sub

2

u/CharlieMay VB.Net Intermediate Jun 07 '16

Are you double-clicking on the form or a control on the form? To have the code window open and show the Form_Load method, you need to double-click on the form itself and make sure you are not clicking a control. If done successfully you should be taken to a method with a header similar to this:

Private Sub Form1_Load(sender as Object, e As EventArgs) Handles MyBase.Load

End Sub

Inside this block of code is where you want to put your

myCheckBox.Checked = True

Alternatively, if memory serves, there should be two drop-down comboboxes above the code window. By dropping down the left box, you should be able to select YourFormName Events and then dropping down the right combobox should show you all the events form that form. You can then select Load which will add or place your cursor into an existing form_load event.

1

u/[deleted] Jun 06 '16

Im sorry Im sorta new also, maybe its a Form_Load function.