📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents real部 As System.Windows.Forms.TextBox
Friend WithEvents complx部 As System.Windows.Forms.TextBox
Friend WithEvents result As System.Windows.Forms.TextBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox0 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.real部 = New System.Windows.Forms.TextBox
Me.complx部 = New System.Windows.Forms.TextBox
Me.TextBox0 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.result = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'real部
'
Me.real部.Location = New System.Drawing.Point(144, 24)
Me.real部.Name = "real部"
Me.real部.Size = New System.Drawing.Size(48, 21)
Me.real部.TabIndex = 0
Me.real部.Text = "2.5"
'
'complx部
'
Me.complx部.Location = New System.Drawing.Point(240, 24)
Me.complx部.Name = "complx部"
Me.complx部.Size = New System.Drawing.Size(64, 21)
Me.complx部.TabIndex = 1
Me.complx部.Text = "4.5"
'
'TextBox0
'
Me.TextBox0.Location = New System.Drawing.Point(104, 24)
Me.TextBox0.Name = "TextBox0"
Me.TextBox0.Size = New System.Drawing.Size(16, 21)
Me.TextBox0.TabIndex = 2
Me.TextBox0.Text = "z"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(200, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(32, 23)
Me.Label1.TabIndex = 3
Me.Label1.Text = "+i"
'
'result
'
Me.result.Location = New System.Drawing.Point(88, 152)
Me.result.Name = "result"
Me.result.Size = New System.Drawing.Size(336, 21)
Me.result.TabIndex = 4
Me.result.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(128, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(16, 23)
Me.Label2.TabIndex = 5
Me.Label2.Text = "="
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(32, 152)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(40, 23)
Me.Label3.TabIndex = 6
Me.Label3.Text = "结果"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(184, 192)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 7
Me.Button1.Text = "运算"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(112, 56)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(24, 21)
Me.TextBox1.TabIndex = 8
Me.TextBox1.Text = "1"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(152, 56)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(24, 21)
Me.TextBox2.TabIndex = 9
Me.TextBox2.Text = "-3"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(192, 56)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(24, 21)
Me.TextBox3.TabIndex = 10
Me.TextBox3.Text = "20"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(232, 56)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(24, 21)
Me.TextBox4.TabIndex = 11
Me.TextBox4.Text = "44"
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(272, 56)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(24, 21)
Me.TextBox5.TabIndex = 12
Me.TextBox5.Text = "54"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(8, 56)
Me.Label4.Name = "Label4"
Me.Label4.TabIndex = 13
Me.Label4.Text = "c0,c1,c2,c3,c4"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(448, 273)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.result)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox0)
Me.Controls.Add(Me.complx部)
Me.Controls.Add(Me.real部)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim I As Integer '循环用的常数
Dim INPUTNUM As Double '输入的常数相的个数
Dim CC(5) As Double '常数相分别的数值
Dim X(50), Y(50) As Double '迭代过程中的实部、虚部的值
Dim TEMP, TEMP1 As Double '计算各过程中的返回值、统计的各项值
Dim real, complx As Double '最终的实部、虚部值
Public Function JISUAN(ByVal X As Double)
TEMP = 0
'fx=C(n)*x^n+C(n-1)*x^(n-1)+....+c1*x+c0
CC(0) = Double.Parse(TextBox1.Text)
CC(1) = Double.Parse(TextBox2.Text)
CC(2) = Double.Parse(TextBox3.Text)
CC(3) = Double.Parse(TextBox4.Text)
CC(4) = Double.Parse(TextBox5.Text)
I = 0
INPUTNUM = 4
While (I < INPUTNUM + 1)
TEMP1 = CC(I) * Math.Pow(X, I)
TEMP = TEMP + TEMP1
I = I + 1
End While
Return TEMP
End Function
Public Function JISUAN1(ByVal X As Double)
TEMP = 0
'fx=C(n)*x^n+C(n-1)*x^(n-1)+....+c1*x+c0
CC(1) = Double.Parse(TextBox2.Text)
CC(2) = Double.Parse(TextBox3.Text)
CC(3) = Double.Parse(TextBox4.Text)
CC(4) = Double.Parse(TextBox5.Text)
I = 1
INPUTNUM = 4
While (I < INPUTNUM + 1)
TEMP1 = CC(I) * I * Math.Pow(X, I - 1)
TEMP = TEMP + TEMP1
I = I + 1
End While
Return TEMP
End Function
Public Function REAL_BU()
'X(K+1)=X(K)-[A(K)*C(K)+B(K)*C(K)]/[C(K)^2+D(K)^2] ///实部的计算公式
X(0) = JISUAN(Double.Parse(real部.Text))
I = 0
While (I > 10)
X(I + 1) = JISUAN(X(I))
End While
complx = X(I)
Return complx
Return real '返回实部计算值
End Function
Public Function COMPLX_BU()
' Y(K+1)=Y(K)-[A(K)*D(K)+B(K)*C(K)]/[C(K)^2+D(K)^2] ///虚部的计算公式
Y(0) = JISUAN1(Double.Parse(complx部.Text))
I = 0
While (I > 10)
Y(I + 1) = JISUAN(Y(I))
End While
complx = Y(I)
Return complx '返回虚部计算值
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'fx=C(n)*x^n+C(n-1)*x^(n-1)+....+c1*x+c0
real = REAL_BU()
complx = COMPLX_BU()
If (TEMP > 0.0000000000001) Then
result.Text = real.ToString + "+" + " " + complx.ToString + "i"
Else
result.Text = real.ToString + " " + complx.ToString + "i"
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -