2017-09-09 23 views

回答

0

使用console.ReadLine從用戶

Sub Main() 
    Dim x As Integer = Console.ReadLine 
    Dim isn As Decimal = Console.ReadLine 
    Dim fsn As Decimal = Console.ReadLine 
    Dim inc As Decimal = Console.ReadLine 
    For m = isn To fsn Step inc 
     Dim r As Double = x * m 
     Dim r_string As String = r.ToString 
     If r_string.Contains(".") Then 
     Else 
      Console.WriteLine(r) 
     End If 
    Next 
    Console.ReadLine() 
End Sub 
+0

可我知道爲什麼有人downvoted這個答案的價值? – Subaz

+0

...變量是一個Console.ReadLine()用戶輸入 –

+0

哦..我會糾正它等待 – Subaz

-1

有很多種方法來實現這一獲得價值,我在我的代碼來實現這一以及註釋掉其他驗證。

Dim x As Integer 
Dim isn As Decimal 
Dim fsn As Decimal 
Dim inc As Decimal 

For m = isn To fsn Step inc 
    Dim r As String = x * m 
    If Not r = int(r) Then 'If IsNumeric(r) = true AndAlso r.ToString().Contains(".") = true OrElse Math.Floor(value) = Math.Ceiling(value) OrElse Integer.TryParse(number, output) Then 
    Else 
     Console.WriteLine(r) 
    End If 
Next 
Console.ReadLine() 
相關問題