ModdersCentral
VB.NET Basic Calculator - Printable Version

+- ModdersCentral (http://modderscentral.com)
+-- Forum: Coding (http://modderscentral.com/forumdisplay.php?fid=4)
+--- Forum: .Net Framework (http://modderscentral.com/forumdisplay.php?fid=5)
+--- Thread: VB.NET Basic Calculator (/showthread.php?tid=46)



VB.NET Basic Calculator - jamie - 07/07/2018

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