我想從一個程序,我以前作出,將平均在一起10個數字,並捕獲例外,如果信件輸入程序。沒有支票的信件舊代碼爲嘗試...趕上...終於檢查字符串VB.Net
Module Module1
Sub Main()
Dim Input As Decimal
Console.WriteLine("Press the numbers you would like to average and press enter after each number.")
Console.WriteLine("After the tenth number all the numbers will be averaged together.")
Input = Console.ReadLine
Console.WriteLine((Input + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine)/10)
Console.ReadKey()
End Sub
End Module
新方案目前我有如下,我有各種各樣的問題,所以任何幫助,將不勝感激。
Module Module1
Public Sub Main()
Dim input As Object
Console.WriteLine("Press the numbers you would like to average and press enter after each number.")
Console.WriteLine("After the tenth number all the numbers will be averaged together.")
input = Console.ReadLine
If Char.IsNumber(Console.ReadLine) Then
Console.WriteLine((Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine + Console.ReadLine)/10)
Console.ReadKey()
End If
If Not IsNumeric(Console.ReadLine) Then
Try
Catch ex As System.Exception
System.Console.WriteLine("Please enter a number")
Finally
System.Console.WriteLine("Try again without entering any letters")
End Try
Console.ReadKey()
End If
End Sub
End Module
你能稍微更清楚一點你所得到的錯誤嗎? –
定義了「各種各樣的問題」......在清潔工人身上有讀寫技巧 – Plutonix
出於某種原因,而不是數字的平均值,它們會以一種奇怪的方式變得越來越多,而且在顯示之前我必須輸入3個不同的字母異常消息。 – user3083405