I want to have something run in a form as soon as the form starts (i don't want to wait for a button to be pressed or anything) anyone know how to do this?
try the form_activated event and if you only want your code to run the first time the form appears, set a flag after running your code and check it before running the code.
If that didnt make sense here's some code. If you want to know why the flag is important, try removing the "tstflag=true" line.
Public Class Form1
Inherits System.Windows.Forms.Form
Dim tstflag As Boolean
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
If Not tstFlag Then
MsgBox("Your code here"
tstflag = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
tstFlag = False
End Sub
end class
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.