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:

    ...I had grown up in a world that was dominated by immature age. Not by vigorous immaturity, but by immaturity that was old and tired and prudent, that loved ritual and rubric, and was utterly wanting in curiosity about the new and the strange. Its era has passed away, and the world it made has crumbled around us. Its finest creation, a code of manners, has been ridiculed and discarded.
    Ellen Glasgow (1873–1945)

    Wise Draco comes, deep in the midnight roll
    Of black artillery; he comes, though late;
    In code corroborating Calvin’s creed
    And cynic tyrannies of honest kings;
    He comes, nor parlies; and the Town, redeemed,
    Gives thanks devout; nor, being thankful, heeds
    The grimy slur on the Republic’s faith implied,
    Which holds that Man is naturally good,
    And—more—is Nature’s Roman, never to be
    scourged.
    Herman Melville (1819–1891)