Jak*_*rew 3 vb.net console-application
我正在制作一个计算机科学的控制台应用程序,如果两个数字相同则显示一条消息,如果它们不同则显示不同的消息.
到目前为止,这是我的代码:
Module Module1
Sub Main()
Dim NumberOne As Integer
Dim NumberTwo As Integer
Console.WriteLine("Enter your first number and then press the enter key")
NumberOne = Console.ReadLine
Console.WriteLine("Now enter your second number and press the enter key")
NumberTwo = Console.ReadLine
If NumberOne = NumberTwo Then
Console.WriteLine("You entered the same two numbers!")
Console.ReadLine()
End If
If NumberOne <= NumberTwo Then
Console.WriteLine("You entered two different numbers")
Console.ReadLine()
End If
End Sub
End Module
Run Code Online (Sandbox Code Playgroud)
这样运行正常,但问题是如果输入两个相同的数字,它表示您输入了相同的数字,但是当您按Enter键时,它会显示另一条消息,表示您输入了两个不同的数字.
有谁知道我怎么能做到只做一个或另一个?
谢谢,
可靠的人
请更改您的代码:
If NumberOne = NumberTwo Then
Console.WriteLine("You entered the same two numbers!")
Console.ReadLine()
Else
Console.WriteLine("You entered two different numbers")
Console.ReadLine()
End If
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
7660 次 |
| 最近记录: |