0
Francesco BalenaによるVisual Basic.net Core Referenceを購入しましたが、Visual Basicを学びたいと思っていましたが、本の最初のコンソールコードサンプルで問題が発生しています。この本は古すぎると思うし、サンプルはもはや今日のVB.netと互換性がなくなっていますか?コンパイラは、()私はサブメインを()不足しているんだけど、フランチェスコの本のサンプルがサブメインを持っていないVB.netでのFactorial Programとバージョンの問題
Module MathFunctions
'A public constant
Public Const DoublePI as Double = 6.2831853
'A private array
Private factValues(169) As Double
'Return the factorial of a number in the range 0-169
Public Function Factorial(ByVal n As Integer) As Double
'evvaluate all possible values in advance during the first call.
If factValues(0) = 0 Then
Dim i As Integer
factValues(0) = 1
For i = 1 To 169
factValues(i) = factValues(i - 1) * CDbl(i)
Next
End If
'check the argument
If n >= 0 And n <= 169 Then
'return the value in the array if argument is in range
Factorial = factValues(n)
Else
'raise an error otherwise
Err.Raise(6, , "Overflow")
End If
End Function
'The following code block (except End Module) is what I added to the code sample, but I'm still not getting any output from the console
Sub Main()
Factorial(32)
End Sub
End Module
すべての.NETプログラムは、OSからプログラムを起動するために 'Main'機能を共有しなければなりません。あなたは、この本がそれを前提としているか早期にそれを言及していることがわかるかもしれません。 – Oded
Sub Main()Factorial(32)End Subを実行しようとしましたが、コンソールに何も出力されていません – user133466
新しいコンソールアプリケーションを作成し、このコードを_new_ファイルに追加します。デフォルトのテンプレートは '' Main' Function'(ない 'Sub') – Oded