Visual Basic programs for beginners with examples

How to write a visual basic program. Visual Basic programs for beginners with examples. How to print a string in visual basic. below are some examples of visual basic programs.

In this tutorial, Will see some basic string operation like how to print string and char in visual basic. Check the visual basic program for mathematical operations.

Let’s start with the basic “Hello World” Project in Visual basic. Start any programming language with some string operation is a really good idea. 

Write a visual basic program to print a string “Hello World”

The below code will print the string value “Hello World”. Console.WriteLine(” “) is used to print any value as an output and the Console.ReadLine() is used to read the next line here we are using it to hold the screen.

Module Module1

    Sub Main()
        Console.WriteLine("Hello World")
        Console.ReadLine()
    End Sub

End Module

Output: Hello World

Visual basic program to print a string variable.

Declare a variable in visual basic is really simple. here in the below code. Dim str As String is a variable decoration. Where str is a variable of string type.

Module Module1

    Sub Main()
        Dim str As String
        str = "Write First program in Visual basic"
        Console.WriteLine(str)
        Console.ReadLine()
    End Sub

End Module

Output: Write First Program in Visual basic

How to Concat two string in Visual basic.

 + or the & operator is used to Concat two or more string in Visual basic. Below is the code to Concat two string in visual basic. Which contains 3 strings str1, str2,str3.

Module Module1

    Sub Main()
        Dim str1, str2, str3 As String
        str1 = "Visual"
        str2 = "Basic"
        str3 = "Program"
        Console.WriteLine(str1 + " " + str2 + " " + str3)
        Console.ReadLine()
    End Sub

End Module

Output: Visual basic program

Please check more examples on visual basic program for beginner

Visual Basic programs with example

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

Java Program for Interview with example

Past Year’s Placement papers for Interview of MNC

2 thoughts on “Visual Basic programs for beginners with examples”

  1. Not sure if anybody else had to do this, but to clear the style completely, I had to remove the at the end of the header.php file otherwise you would get rendered borders. this happened in safari 4.0.1 and firefox… whatever version I have installed. I don’t know, I never use it.

Comments are closed.