Question call a function?

tobyhuton

New member
Joined
Jun 8, 2015
Messages
1
Programming Experience
1-3
How can I call a function in the Private Sub Form1_Load.

I want to be able to call items like

Code:
item1.Enabled = False
item2.Enabled = False
Thanks
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,295
Location
Sydney, Australia
Programming Experience
10+
I'm afraid that your question doesn't really make much sense. If you want to call a method in the Load event handler then go ahead and call it. There's nothing stopping you.

That said, the code snippet you posted demonstrates setting properties, not calling methods. It's really not clear what you want to do and what your actual problem doing it is.
 

Sherm

New member
Joined
Aug 15, 2015
Messages
2
Programming Experience
Beginner
Here you go :) Is this what you need?


If you want your function to be called when the form1 starts

Public Class Form1

        Function Do_Following() 'This is the function we are calling

        item1.Enabled = False 
        item2.Enabled = False

        Return Nothing 
    End Function

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        Do_Following() 'call the function which we created earlier
    End Sub

End Class



If you want your function to be called when a button is clicked


Public Class Form1

        Function Do_Following() 'This is the function we are calling

        item1.Enabled = False 
        item2.Enabled = False

        Return Nothing 
    End Function

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Do_Following() 'call function

    End Sub

End Class
 
Last edited:
Top Bottom