Visual Basic | VB.NET exercises and solutions programming


Visual Basic or VB.NET variables exercises

Exercise 1: Write VB.NET code to declare a variable to store the age of a person.

Then the output of the program is as an example shown below:

You are 20 years old.

Solution:

Module Module1

Sub Main()

Dim age As Integer = 20 'declaring variable and assign 20 to it.
Console.WriteLine("You are " & age & " years old.")

Console.ReadLine()

End Sub

End Module

Exercise 2:Write VB.NET code to display the asterisk pattern as shown below:

*****

*****

*****

*****

*****

Solution:

Module Module1

Sub Main()

Console.WriteLine("*****")
Console.WriteLine("*****")
Console.WriteLine("*****")
Console.WriteLine("*****")
Console.WriteLine("*****")
Console.ReadLine()


End Sub

End Module

Exercise 3: Write VB.NET code to declare two integer variables, one float variable, and one string variable and assign 10, 12.5, and "VB.NET programming" to them respectively.

Then display their values on the screen.

Solution:

Module Module1

Sub Main()

Dim x As Integer
Dim y As Single
Dim s As String
x = 10
y = 12.5F
s = "I like VB programming."
Console.WriteLine(x)
Console.WriteLine(y)
Console.WriteLine(s)
Console.ReadLine()

End Sub

End Module

Exercise 4: Write VB.NET code to prompt a user to input his/her name and then the output will be shown as an example below:

Hello John!

Solution:

Module Module1

Sub Main()

Dim name As String
Console.Write("Please enter your name:")
name = Console.ReadLine()
Console.WriteLine("Hello {0}!", name)
Console.ReadLine()

End Sub

End Module




Comments

8==D~ comment

 8==D~

cx


2016-04-12
Best at Counter Strike comment

 Best at Counter Strike

All these kids think they r good but supreme life .


2016-04-12
Shutut comment

 Shutut

ƝōōŢ ƝōōŢ


2016-04-12
Stomedy comment

 Stomedy

When you eat, I will be there.
When you sleep, I will be there.
When you are in the shower, I will be there.


2016-04-12
$$$$$$$$$$$$$$ comment

 $$$$$$$$$$$$$$

2$ suckie suckie


2016-04-12
OMG look at this neat Runescap comment

 OMG look at this neat Runescap

www.youtube.com/watch=?gewtrektkid69


2016-04-12
Johnny Sins comment

 Johnny Sins

!!!!!!OMG LOOK AT THIS AWESOME WEIGHT LOSS TRICK WITH ONLY ONE INSANE STEP!!!!! https://www.youtube.com/user/tailopezofficial


2016-04-12
PCS comment

 PCS

type some numbers in the comments theyre f'ed up
0928512-472489073098352


2016-04-12
#RoT07 comment

 #RoT07

Join RoT07 group on Steam


2016-04-12
PCS comment

 PCS

type some numbers in the comments theyre f'ed up
0928512-472489073098352


2016-04-12
cx comment

 cx

okaylol cx #RoT07


2016-04-12
React Movie World comment

 React Movie World

Wow, its going to be Great program, I'm going to run it


2016-04-12
React Movie World comment

 React Movie World

Wow, its going to be Great program, I'm going to run it


2016-04-12
lol comment

 lol

that comment though


2016-04-12
Point Cook Senior Student comment

 Point Cook Senior Student

This work is boring as fuck and annoying, why do we do this shit.


2016-04-12
saitama comment

 saitama

are there any codes for windows form?


2016-02-09
Hertta comment

 Hertta

Good answers..


2015-09-23
its good tutorial comment

 its good tutorial

its nice n simplifies


2015-07-22
Sruthi comment

 Sruthi

Can add more Examples with advanced concepts


2014-11-06
Ripu mardan Lal comment

 Ripu mardan Lal

I m Preparing for VB.net Exam may it help me .....


2014-05-21
twat  comment

 twat

i am doing a project for wjce computing :) and it is shit


2013-09-17
looks  comment

 looks

cool


2013-09-17
CAPTCHA image




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.