使用C#将int添加到textbox.text(int to textbox.text with C#)

编程入门 行业动态 更新时间:2024-10-27 06:19:09
使用C#将int添加到textbox.text(int to textbox.text with C#)

使用VB我没有这个方法的错误

Private Sub But_Leer_Click(sender As Object, e As EventArgs) Handles But_Leer.Click Dim INT(3) As Integer ProEasy.ReadDevice32("LT4000_1.#INTERNAL", "Valor1", INT, 1) TextBox1.Text = INT(0)

但是使用C#,在向Textbox1.text分配“Valor”int时出错。 需要一个字符串:

private void button2_Click(object sender, EventArgs e) { int[] Valor = new int[3]; ProEasy.ReadDevice32("LT4000_1.PLC1", "MWO", out Valor, 1); textBox1.Text = **Valor**[0];

谁知道为什么? 我刚开始使用VB和C#语言

With VB I have no error with this method

Private Sub But_Leer_Click(sender As Object, e As EventArgs) Handles But_Leer.Click Dim INT(3) As Integer ProEasy.ReadDevice32("LT4000_1.#INTERNAL", "Valor1", INT, 1) TextBox1.Text = INT(0)

But with C#, I have an error when assigning "Valor" int to Textbox1.text. A string is required:

private void button2_Click(object sender, EventArgs e) { int[] Valor = new int[3]; ProEasy.ReadDevice32("LT4000_1.PLC1", "MWO", out Valor, 1); textBox1.Text = **Valor**[0];

Anyone knows why? I just starting with VB and C# language

最满意答案

Valor[0]返回int ,需要将其转换为string

textBox1.Text = Valor[0].ToString();

Valor[0] returns int, you need to convert it to string

textBox1.Text = Valor[0].ToString();

更多推荐

本文发布于:2023-07-21 23:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1214865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:int   textbox   text

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!