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

blank comment

 blank

can someone give me a site that have VB.NET samples


2017-11-20
VB6 Programming comment

 VB6 Programming

VB6 programming is still more popular then .Net


2017-08-01
computer study comment

 computer study

check the more program of vb.net
www.youtube.com/c/computerstudy


2017-06-21
computer study comment

 computer study

check the more program of vb.net


2017-06-21
computer study comment

 computer study

check the more program of vb.net www.youtube.com/c/computerstudy


2017-06-21
computer study comment

 computer study

check the more program of vb.net www.youtube.com/c/computerstudy


2017-06-21
computer study comment

 computer study

check the more program of vb.net www.youtube.com/c/computerstudy


2017-06-21
shardul comment

 shardul

technical website pe bhi Allah aur ramadan? are kuch to khudko bahar nikalo.. majhab ki bohot chhotisi duniya se... duniya me aur kuch nahi hai kya experience karne ke liye...express karne ke liye... kitni chhoti mentality dikhate ho tum log....


2017-06-13
majinder comment

 majinder

ak47 just a prank


2017-06-01
Abdul comment

 Abdul

MAY ALLAH PROTECT US


2017-06-01
ayy comment

 ayy

happy ramadan


2017-06-01
PCL comment

 PCL

MAY ALLAH PROTECT US


2017-06-01
US Muhammad comment

 US Muhammad

Very interesting and helpul


2017-04-12
US Muhammad comment

 US Muhammad

Very interesting and helpul


2017-04-12
US Muhammad comment

 US Muhammad

Very interesting and helpul


2017-04-12
US Muhammad comment

 US Muhammad

Very interesting and helpul


2017-04-12
Brev comment

 Brev

That was bad. Could have used loops for Exercise 2. Exercise 3 could have been set the variable on 1 line rather than using 2 lines for each. Also when using the console application you should have used Console.ReadKey() so that the user/dev could actually have the console window up and read what is there. Exercise 5 was the only decent one however still pretty bad.


2017-03-15
sam comment

 sam

0548913205491


2017-02-15
Jon Moss 1 comment

 Jon Moss 1

kys


2017-01-24
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.