Visual Basic programs for beginners with examples

Visual Basic programs for beginners with examples

Basic Vb programs

Example 2.1.1

Private Sub Form_Load ( )

Form1.show

Print “Welcome to Visual Basic tutorial”

End Sub

 

Example 2.1.2

Private Sub Form_Activate ( )

Print 20 + 10
Print 20 - 10
Print 20 * 10
Print 20 / 10

End Sub

 

 

You can also use the + or the & operator to join two or more texts (string) together like in example 2.1.4 (a) and (b)

Example 2.1.4(a)

Private Sub

A = “Tom”
B = “likes”
C = “to”
D = “eat”
E = “burger”
Print A + B + C + D + E

End Sub

Example 2.1.4(b)

Private Sub

A = “Tom”
B = “likes”
C = “to”
D = “eat”
E = “burger”
Print A & B & C & D & E

End Sub

Write a VB program to convert Celsius to Fahrenheit

Private Sub Command1_Click()
Dim c, f As Integer
c = Text1.Text
f = 9 * c / 5 + 32
Text2.Text = f


End Sub

 

Add a Comment

Your email address will not be published. Required fields are marked *

ten − seven =