【问题标题】:Making a Console Application ask something and receive input使控制台应用程序询问某些内容并接收输入
【发布时间】:2016-09-07 22:22:48
【问题描述】:

我在高中学习基础编程,并负责一个项目,在该项目中我要制作一个向老师问好的程序,并用一段描述为什么编程在当今时代很有价值。

我最初的想法是制作一个程序来问候并询问老师一个问题,即他们是否想知道为什么编程很有价值。当控制台询问问题时,将有两个选项:是或否。每个选项都有自己的文本输出。

 REM Period 6 Class Project for (My Name)
    Dim input = Console.ReadLine
    Dim Yes = input
    Dim No = input
    Console.WriteLine("Hello, would you like to get an explanation as to why programming is valuable?")
    input = Console.ReadLine
    If input = Yes Then
        Console.WriteLine("Well the reason why...")
    End If

我遇到的问题实际上是让文本出现在应用程序上,以及接收关于代码是否正确的输入。

【问题讨论】:

  • 它看起来像 vb.net。是它还是你想要经典的基本款?
  • 我正在使用 Visual Basic。

标签: windows visual-studio console-application basic


【解决方案1】:

看看如果..然后..否则

input=input.ToLower().Trim()
If input="yes" then
 ...
ElseIf  input="no" then
...
Else
..' unexpected answer
End if

【讨论】:

  • 所以代码一开始是正确的?当我 ctrl + f5 时,我没有在控制台上显示任何文本。
  • 在末尾添加 Console.Read() 以便输出后不会立即退出
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-09-17
  • 2012-10-02
  • 1970-01-01
  • 2021-04-01
  • 1970-01-01
  • 2013-02-23
相关资源
最近更新 更多