简单的代码错误 - 需要解决方案 [英] Simple code error - Need a solution
问题描述
我刚刚开始在大学计算,在给我们的第一个任务是找到一个Visual Basic教程,我找到了一个制作货币转换器但是在制作它的过程中我发现了一个错误我无法解决。
I've just started Computing at College at the first task given to us was to find a Visual Basic tutorial, I found one to make a Currency Converter but in the process of making it I've found a error I can't work around.
这些是代码行:
功能CuConv(ByVal money As Double)As Double
     如果Combobox.Text ="尼日利亚",然后
         返回Math.Round(Nigerian_Naira *货币,2)
      ElseIf Combobox.Text ="USA"然后
         返回Math.Round(US_Dollar * Currency,2)
      ElseIf Combobox.Text =" Kenyan"然后
         返回Math.Round(Kenyan_Shilling *货币,2)
      ElseIf Combobox.Text =" Brazil"然后
         返回Math.Round(Brazillian_Real *货币,2)
      ElseIf Combobox.Text ="Canada"然后
         返回Math.Round(Canadian_Dollar * Currency,2)
      ElseIf Combobox.Text =" india"然后
         返回Math.Round(Indian_Rupee * Currency,2)
      ElseIf Combobox.Text ="菲律宾"然后
         返回Math.Round(Philippine_Peso *货币,2)
      ElseIf Combobox.Text ="Indonesia"然后
         返回Math.Round(Indonesian_Rupiah * Currency,2)
     结束如果
 结束函数
Function CuConv(ByVal money As Double) As Double
If Combobox.Text = "Nigeria" Then
Return Math.Round(Nigerian_Naira * Currency, 2)
ElseIf Combobox.Text = "USA" Then
Return Math.Round(US_Dollar * Currency, 2)
ElseIf Combobox.Text = "Kenyan" Then
Return Math.Round(Kenyan_Shilling * Currency, 2)
ElseIf Combobox.Text = "Brazil" Then
Return Math.Round(Brazillian_Real * Currency, 2)
ElseIf Combobox.Text = "Canada" Then
Return Math.Round(Canadian_Dollar * Currency, 2)
ElseIf Combobox.Text = "india" Then
Return Math.Round(Indian_Rupee * Currency, 2)
ElseIf Combobox.Text = "Philippine" Then
Return Math.Round(Philippine_Peso * Currency, 2)
ElseIf Combobox.Text = "Indonesia" Then
Return Math.Round(Indonesian_Rupiah * Currency, 2)
End If
End Function
,错误是 - 没有为所有返回行的类型'双打'和'文本框'定义操作符'*'
and the error is - Operator '*' is not defined for types 'Doubles' and 'Textbox' for all return lines
感谢任何帮助
Any help is appreciated
推荐答案
我刚才开始计算在大学的第一个任务是找到一个Visual Basic教程,我找到一个制作货币转换器,但在制作过程中我发现了一个错误,我无法解决。
I've just started Computing at College at the first task given to us was to find a Visual Basic tutorial, I found one to make a Currency Converter but in the process of making it I've found a error I can't work around.
这些是代码行:
功能CuConv(ByVal money As Double)As Double
     如果Combobox.Text ="尼日利亚",然后
         返回Math.Round(Nigerian_Naira *货币,2)
      ElseIf Combobox.Text ="USA"然后
         返回Math.Round(US_Dollar * Currency,2)
      ElseIf Combobox.Text =" Kenyan"然后
         返回Math.Round(Kenyan_Shilling *货币,2)
      ElseIf Combobox.Text =" Brazil"然后
         返回Math.Round(Brazillian_Real *货币,2)
      ElseIf Combobox.Text ="Canada"然后
         返回Math.Round(Canadian_Dollar * Currency,2)
      ElseIf Combobox.Text =" india"然后
         返回Math.Round(Indian_Rupee * Currency,2)
      ElseIf Combobox.Text ="菲律宾"然后
         返回Math.Round(Philippine_Peso *货币,2)
      ElseIf Combobox.Text ="Indonesia"然后
         返回Math.Round(Indonesian_Rupiah * Currency,2)
     结束如果
 结束函数
Function CuConv(ByVal money As Double) As Double
If Combobox.Text = "Nigeria" Then
Return Math.Round(Nigerian_Naira * Currency, 2)
ElseIf Combobox.Text = "USA" Then
Return Math.Round(US_Dollar * Currency, 2)
ElseIf Combobox.Text = "Kenyan" Then
Return Math.Round(Kenyan_Shilling * Currency, 2)
ElseIf Combobox.Text = "Brazil" Then
Return Math.Round(Brazillian_Real * Currency, 2)
ElseIf Combobox.Text = "Canada" Then
Return Math.Round(Canadian_Dollar * Currency, 2)
ElseIf Combobox.Text = "india" Then
Return Math.Round(Indian_Rupee * Currency, 2)
ElseIf Combobox.Text = "Philippine" Then
Return Math.Round(Philippine_Peso * Currency, 2)
ElseIf Combobox.Text = "Indonesia" Then
Return Math.Round(Indonesian_Rupiah * Currency, 2)
End If
End Function
,错误是 - 没有为所有返回行的类型'双打'和'文本框'定义操作符'*'
and the error is - Operator '*' is not defined for types 'Doubles' and 'Textbox' for all return lines
感谢任何帮助
Any help is appreciated
您没有足够的帮助提供任何帮助。什么是,例如,"Nigerian_Naira"?
You haven't shown enough for anyone to help. What is, for example, "Nigerian_Naira"?
*****
顺便说一句,为了钱,你最好是使用十进制类型。
As an aside, for money, you're better to use a Decimal type.
这篇关于简单的代码错误 - 需要解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!