Visual Basic - Example Code

Example Code

The following code snippet displays a message box saying "Hello, World!" as the window loads:

Private Sub Form_Load ' Execute a simple message box that will say "Hello, World!" MsgBox "Hello, World!"End Sub

This snippet makes a counter that moves up 1 every second (a label and a timer control need to be added to the form for this to work):

Option Explicit Dim Count As Integer Private Sub Form_Load Count = 0 Timer1.Interval = 1000 ' units of milliseconds End Sub Private Sub Timer1_Timer Count = Count + 1 Label1.Caption = Count End Sub

Read more about this topic:  Visual Basic

Famous quotes containing the word code:

    Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.
    Alice Foote MacDougall (1867–1945)

    Acknowledge your will and speak to us all, “This alone is what I will to be!” Hang your own penal code up above you: we want to be its enforcers!
    Friedrich Nietzsche (1844–1900)