Christeta

Visual Basic Sample Code
About Visual Basic | Sample codes | About Me | My Pic

Sample Codes 

Here are some examples of the language:

Program to display a pop-up message box with the words "Hello World" on it:

Sub Main()

    MsgBox("Hello World")

End Sub

Program to display a input box:

 Sub Main()

    Dim a As String

    a = InputBox("Enter your name:")

     MsgBox (a)

End Sub

Running Another Application Using Visual Basic:
 
 
 Private Sub Run_Notepad()
 
       Shell("notepad.exe", MinimizedFocus)
 
       'This would open Notepad, as Notepad is in the system folder.
 
       '%SystemRoot% is an environment variable containing the path  to the system folder.
 
       'which is not needed as it is already in the system folder
 
End Sub
 
Printing multiplication table of 5 on form:
 
 
Private Sub PrintMul_Click()
 
Dim I As Integer
 
     For I = 1 To 10
 
     Print 5; " x "; I; " = "; 5 * i 
 
     Next I
 
End Sub