如何在方程式中使用列表框? [英] How can I use list boxes in equations?

查看:66
本文介绍了如何在方程式中使用列表框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我正在编写一个任务代码,我无法弄清楚如何在方程中使用我的列表框



就像如何使用列表框中的变量一样。我需要将两个变量一起添加并在标签上显示,我无法弄清楚该怎么做。



澄清我在视觉基础知识中工作



我尝试了什么:



我尝试过使用If if then对于下一个,还有很多其他人。我一直试图解决这个问题超过一个星期。

Hello

I'm working on a code for an assignment and I can't figure out how to use my list boxes in equation

like how to use the variables in the list boxes already. I need to add both variables together and present them on a label which I can not figure out how to do.

To clarify I'm working in visual Basics

What I have tried:

I've tried using If then, for next, and many others. I've been trying to figure this out for more than a week now.

推荐答案

我们无法真正帮助你专门基于这一点 - 我们不能看看你的列表框中有什么!

但是猜测,列表框中包含字符串,你不能直接将它们加在一起。

相反,转换首先是字符串到数字:

We can't really help you specifically based on that little - we can't see what you have in your list boxes!
But at a guess, the list boxes contains strings, and you can't add them together directly.
Instead, convert the strings to numbers first:
Dim valueFromListBox1 As String = "666"
Dim valueFromListBox2 As String = "333"
Dim value1 As Integer
Dim value2 As Integer

If Integer.TryParse(valueFromListBox1, value1) AndAlso Integer.TryParse(valueFromListBox2, value2) Then
    Dim result As Integer = value1 + value2
    Console.WriteLine(result)
End If


这篇关于如何在方程式中使用列表框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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