Posted by: Sourav | December 21, 2012

A simple calculator in Visual Basic


Dim a As Integer = Nothing
Dim b As Integer = Nothing
Dim c As String = Nothing
Dim d As Double = Nothing

 

Console.WriteLine(“Please enter the first number:”)
a = Console.ReadLine
Console.WriteLine(“Please enter the second number:”)
b = Console.ReadLine
Console.WriteLine(“Please enter the operation you want to perform:”)

c = Console.ReadLine
If c = “+” Then
d = a + b
End If

If c = “-” Then
d = a – b
End If

If c = “*” Then
d = a * b
End If

If c = “/” Then
d = a / b
End If

If c = “MOD” Then
d = a Mod b
End If
Console.WriteLine(“The answer is ” & d)

Console.ReadLine()

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: