منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[VB.NET] سؤال في console - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [VB.NET] سؤال في console (/showthread.php?tid=28064)



سؤال في console - farfour - 29-12-18

السلام عليكم
ممكن مساعدة بسيطة يا اصدقاء

اريد عند كتابة رقم واحد في console يقوم بهذا الامر
كود :
   Console.WriteLine("Type a number and press Enter")
   num1 = Console.ReadLine()
   Console.WriteLine("Type another number to add to it and press Enter")
   num2 = Console.ReadLine()
   answer = num1 + num2
   Console.WriteLine("The answer is " & answer)
   Console.ReadLine()
و اذا ادخلت رقم 2 يقوم بهذا الامر
كود :
   Console.WriteLine("Type a number and press Enter")
   num1 = Console.ReadLine()
   Console.WriteLine("Type another number to add to it and press Enter")
   num2 = Console.ReadLine()
   answer = num1 - num2
   Console.WriteLine("The answer is " & answer)
   Console.ReadLine()



RE: سؤال في console - trakktour - 29-12-18

و عليكم السلام
تفضل
كود :
Public num1 As Integer
   Public num2 As Integer
   Public answer As Integer

   Sub Main()
       System.Console.WriteLine("Welcome")
       Module1.trakktour()
   End Sub
   Sub trakktour()
       System.Console.WriteLine("Pick a command:")
       System.Console.WriteLine("1) Addition")
       System.Console.WriteLine("2) Soustraction")
       Select Case Console.ReadLine
           Case "1" : Module1.Addition()
           Case "2" : Module1.Soustraction()
           Case Else : Module1.trakktour()
       End Select
   End Sub
   Sub Addition()
       Console.WriteLine("Type a number and press Enter")
       num1 = Console.ReadLine()
       Console.WriteLine("Type another number to add to it and press Enter")
       num2 = Console.ReadLine()
       answer = num1 + num2
       Console.WriteLine("The answer is " & answer)
       Console.ReadLine()

   End Sub
   Sub Soustraction()
       Console.WriteLine("Type a number and press Enter")
       num1 = Console.ReadLine()
       Console.WriteLine("Type another number to add to it and press Enter")
       num2 = Console.ReadLine()
       answer = num1 - num2
       Console.WriteLine("The answer is " & answer)
       Console.ReadLine()

   End Sub