单击按钮时出现奇怪的错误。救命?

单击按钮时出现奇怪的错误。救命?

问题描述:

[该程序是一个Windows应用程序,用Visual Basic编写]  您好,我正在制作转换器,当我点击go按钮时,我收到此错误:

[The program is a Windows Store app, being written in Visual Basic]  Hello, I'm making a converter and when I click the go button, I get this error:

这是单击按钮时执行的代码(tempfrom和tempto是组合框):

This is the code the button executes when clicked (tempfrom and tempto are combo boxes):

(粗体表示发生错误的位置)

(Bold indicates where the error occurred)

~TechPerson32

~ TechPerson32

如果你的组合框绑定了某些东西,你需要将它强制转换为它所显示的类型类。  如果它只是一个字符串列表,我会尝试这个。

If your combobox is bound to something you will need to cast it to the type class it is showing.   If it is just a list of strings I would try this.

if tempfrom .SelectedItem.ToString()=" Fahrenheit"然后

如果它绑定到类

If DirectCast(tempfrom.SelectedItem,MyClass ).MyProperty ="Fahrenheit"
然后