以疊代的方式找出小數1位的解:
求出10的平方根 3.15
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim X As Double = 1.0
Dim Y, Y1, Y2 As Double
Dim P, I As Double
Y1 = Val(TextBox1.Text)
TextBox3.Text = ""
Y = Math.Round(Math.Sqrt(Y1) + 0.8)
TextBox4.Text = Y.ToString("#.###")
For I = X To Y Step 0.05
P = I * I
Y2 = (P - Y1)
TextBox5.Text &= Y2.ToString("#.###") & vbCrLf
If Y2 < 0 Then
TextBox3.Text &= I.ToString("#.####") & "*" & I.ToString("#.####") & "=" & P.ToString("#.####") & vbCrLf
End If
Next
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
沒有留言:
張貼留言