Hello to the people of the internet!
I am just starting out learning Visual Basic 2010 express. My knowledge is limited but what I would like to know is when the application is run, instead of clicking on a button to initiate (or call) a sub to execute code, can i get the application to call the sub?
For example: In console visual basic you have Sub Mains() and whatever you put in there, it just simply executes each line. However since i have started to learn Visual basic two days ago I have learned that the windows application forms subs have to be executed with a button or some form of user action.
I want the application to open and run a Sub straight away gathering data without any user interaction and start displaying information in the form. I have spent hours today trying to find the answer and still no joy.
here is my code so far as a practice run:
Public Class Form1
Private Sub lblVoltage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblVoltage.Click
Dim num As Integer
Do
num = num + 1
lblVoltage.Text = num
lblVoltage.Refresh()
System.Threading.Thread.Sleep(300)
Loop Until num = 9
End Sub
End Class
So obviously I cannot write this code outside a sub as it will simply do nothing. I have to put it in a sub and use the mouse to click on the Label to initiate the lines of code. How do I get code to execute without human interaction?
Cheers!
Mathew
:)
I am just starting out learning Visual Basic 2010 express. My knowledge is limited but what I would like to know is when the application is run, instead of clicking on a button to initiate (or call) a sub to execute code, can i get the application to call the sub?
For example: In console visual basic you have Sub Mains() and whatever you put in there, it just simply executes each line. However since i have started to learn Visual basic two days ago I have learned that the windows application forms subs have to be executed with a button or some form of user action.
I want the application to open and run a Sub straight away gathering data without any user interaction and start displaying information in the form. I have spent hours today trying to find the answer and still no joy.
here is my code so far as a practice run:
Public Class Form1
Private Sub lblVoltage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblVoltage.Click
Dim num As Integer
Do
num = num + 1
lblVoltage.Text = num
lblVoltage.Refresh()
System.Threading.Thread.Sleep(300)
Loop Until num = 9
End Sub
End Class
So obviously I cannot write this code outside a sub as it will simply do nothing. I have to put it in a sub and use the mouse to click on the Label to initiate the lines of code. How do I get code to execute without human interaction?
Cheers!
Mathew
:)