ModdersCentral

Full Version: VB.NET Basic Calculator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
function add(x, y) 
  return x + y
end function
function subtract(x, y) 
  return x - y
end function
function multiply(x, y) 
  return x * y
end function
function divide(x, y) 
  return x / y
end function

console.writeline("Select symbol.")
console.writeline("1.add\n2.sub\n3.mul\n4.div") 

console.writeline("Enter choice (1,2,3 or 4):")
dim choice  as integer= integer.parse(console.readline)

console.writeline("Enter first number: ")
dim  num1 as integer= integer.parse(console.readline)

console.writeline("Enter second number:")
dim num2  as integer= integer.parse(console.readline)
if choice = "1" then
  console.writeline(num1 & "+" & num2 & "=" & add(num1,num2))

else if choice = "2" then
  console.writeline(num1 & "-" & num2 & "=" & subtract(num1,num2))

else if choice = "3" then
  console.writeline(num1 & "*" & num2 & "=" & multiply(num1,num2))

else if choice = "4" then
  console.writeline(num1 & "/" & num2 & "=" & divide(num1,num2))
else 
  console.writeline("Invalid symbol")
end if
www.000webhost.com