-1

可能重复:
Visual Basic Friend 错误

我正在尝试创建一个程序来使用不同的子进行更改。到目前为止,我只是在研究美元和季度,但我遇到了一些重大问题。任何人都可以帮忙吗?提前致谢。

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
4

2 回答 2

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
于 2012-10-17T18:55:03.637 回答
0

NumberCoin()方法中未定义。您必须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
于 2012-10-17T18:55:54.857 回答