我正在尝试创建一个使用不同子进行更改的程序。到目前为止,我只是在处理美元和季度,但我有一些重大问题。有人可以帮忙吗?提前谢谢。
Option Explicit On
'Option Strict On
Imports System
Module Conversion
Sub Coin()
Number = (Number mod 1.00)
Console.Writeline(Number)
Number = (Number mod 0.25)
Console.Writeline(Number)
End Sub
Sub Main()
Console.Write("Enter the Canadian dollar amount: ")
Dim input As Decimal = Console.ReadLine()
Dim Number As Decimal = Input
Coin()
End Sub
End Module
答案 0 :(得分:1)
Coin
无法看到Number
。您必须将Number
作为参数传递给Coin()
,如下所示:
Sub Main()
Console.Write("Enter the Canadian dollar amount: ")
Dim input As Decimal = Console.ReadLine()
Dim Number As Decimal = Input
Coin(Number)
End Sub
Sub Coin(Number as Decimal)
Number = (Number mod 1.00)
Console.Writeline(Number)
Number = (Number mod 0.25)
Console.Writeline(Number)
End Sub
答案 1 :(得分:0)
Number
未在Coin()
方法中定义。您必须让Coin()
获取参数或让Number
成为Coin()
可访问的模块成员
例如:
Sub Coin(Byval Number as Decimal)
Number = (Number mod 1.00)
Console.Writeline(Number)
Number = (Number mod 0.25)
Console.Writeline(Number)
End Sub