从输入中读取变量 [英] Read variable from input

查看:94
本文介绍了从输入中读取变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个程序,使用用户输入的变量,该程序将返回该变量的当前值.

I'm trying to create a program that, with the input of a variable from the user it returns the current value of that variable. 

程序将输入作为字符串读取,因此它返回字符串而不是值.

The program reads the input as a string and so it returns the string instead of the value.

有人可以帮助我吗?


推荐答案

你好,

如果您要从控制台应用程序中查找输入,这是一个简单的示例.

If you are looking for input from a console app, here is a simple example. 

Dim intValue As Integer = 0
Dim value As String = Console.ReadLine
If Integer.TryParse(value, intValue) Then
    ' here we have a valid integer in intValue
Else
    ' value did not contain a valid integer
End If

从文本框

Dim intValue As Integer = 0
Dim value As String = TextBox1.Text
If Integer.TryParse(value, intValue) Then
    ' here we have a valid integer in intValue
Else
    ' value did not contain a valid integer
End If

如果您以其他方式接收输入,请在输入框中说明输入的方式.在表单项目等上通过命令行传递值.

If you are receiving input in a different manner please indicate how the input is coming in e.g. passing a value via the command line on a forms project etc.


这篇关于从输入中读取变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆