No active form yet
The error happened cause there's no active form yet
you can do one of two
change the form1.activeform with me
so your code will be
"Me.Opacity = 0.5"
'this to avoid the 1st error on load
dim flag as integer = 0 'on the form level