【VB开源代码栏目提醒】:网学会员--在 VB开源代码编辑为广大网友搜集整理了:求解一元二次方程的VB源代码(可以求共轭复根) - 研究报告绩等信息,祝愿广大网友取得需要的信息,参考学习。
VERSION 5.00Begin
VB.Form Form1 Caption 求解一元二次方程 ClientHeight 3360 ClientLeft 555 ClientTop 1155 ClientWidth 5760 KeyPreview -1 True LinkTopic Form1 ScaleHeight 3360 ScaleWidth 5760 Begin
VB.CommandButton Command2 Caption 清 空F2 Height 375 Left 3480 TabIndex 12 Top 2760 Width 1695 End Begin
VB.CommandButton Command1 Caption 运 算F1 Height 375 Left 600 TabIndex 11 Top 2760 Width 1695 End Begin
VB.TextBox Text3 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 4200 TabIndex 6 Top 720 Width 1335 End Begin
VB.TextBox Text2 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 2400 TabIndex 5 Top 720 Width 1335EndBegin
VB.TextBox Text1 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 480 TabIndex 4 Top 720 Width 1335EndBegin
VB.Label Label10 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 615 Left 600 TabIndex 14 Top 1680 Visible 0 False Width 5055EndBegin
VB.Label Label9 Caption x BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 120 TabIndex 13 Top 1680 Visible 0 False Width 375EndBegin
VB.Label Label8 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 615 Left 600 TabIndex 10 Top 2040 Width 5055EndBegin
VB.Label Label7 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 615 Left 600 TabIndex 9 Top 1320 Width 5055EndBegin
VB.Label Label6 Caption x2 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 120 TabIndex 8 Top 2040 Width 375EndBegin
VB.Label Label5 Caption x1 BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 120 TabIndex 7 Top 1320 Width 375EndBegin
VB.Label Label4 Caption c: BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 3960 TabIndex 3 Top 720 Width 255EndBegin
VB.Label Label3 Caption b: BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 2040 TabIndex 2 Top 720 Width 255EndBegin
VB.Label Label2 Caption a: BeginProperty Font Name 宋体 Size 10.5 Charset 134 Weight 400 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty Height 375 Left 240 TabIndex 1 Top 720 Width 240 End Begin
VB.Label Label1 Caption 求解一元二次方程 BeginProperty Font Name 隶书 Size 15.75 Charset 134 Weight 700 Underline 0 False Italic 0 False Strikethrough 0 False EndProperty ForeColor H00800000 Height 375 Left 1560 TabIndex 0 Top 180 Width 2850 EndEndAttribute
VB_Name Form1Attribute
VB_GlobalNameSpace FalseAttribute
VB_Creatable FalseAttribute
VB_PredeclaredId TrueAttribute
VB_Exposed FalsePrivate Sub Form_loadCommand1.Caption 运 算F1 这两句
代码是防止此程序在其他电脑上运行时按钮上的字幕只显示第一个字。
Command2.Caption 清 空F2End SubPrivate Sub Command1_ClickDim a b c d x x1 x2 realpart imagpart As Double 若将 x1x2x 定义为 String,则当修复-1 0 And LeftStrx 1 . Then 同上。
x 0 x End If If x 0 And MidStrx 2 1 . Then x -0 Absx End If Label5.Visible False Label6.Visible False Label7.Visible False Label8.Visible False Label9.Visible True Label10.Visible True Label10.Caption x End If If d 0 Then realpart -b / 2 a imagpart Sqr-d / 2 a Label5.Visible True Label6.Visible True Label7.Visible True Label8.Visible True Label9.Visible False Label10.Visible False If realpart 0 Then If Absimagpart 1 Then Label7.Caption i Label8.Caption -i Else If LeftStrAbsimagpart 1 . Then Label7.Caption FormatAbsimagpart 0. i 运用格式化输出函数加上被
VB 省略的“0” 。
Label8.Caption - Format-Absimagpart 0. i Else Label7.Caption StrAbsimagpart i Label8.Caption - StrAbsimagpart i End If End If Else If realpart O And LeftStrrealpart 1 . Then If Absimagpart 1 Then Label7.Caption 0 Strrealpart i Label8.Caption 0 Strrealpart -i Else If LeftStrAbsimagpart 1 . Then Label7.Caption 0 Strrealpart FormatAbsimagpart0. i Label8.Caption 0 Strrealpart - FormatAbsimagpart0. i Else Label7.Caption 0 Strrealpart StrAbsimagpart i Label8.Caption 0 Strrealpart - StrAbsimagpart i End If End If Else If realpart 0 And MidStrrealpart 2 1 . Then If Absimagpart 1 Then Label7.Caption -0 StrAbsrealpart i Label8.Caption -0 StrAbsrealpart -i Else If LeftStrAbsimagpart 1 . Then Label7.Caption -0 StrAbsrealpart FormatAbsimagpart0. i Label8.Caption -0 StrAbsrealpart - FormatAbsimagpart0. i Else Label7.Caption -0 StrAbsrealpart StrAbsimagpart i Label8.Caption -0 StrAbsrealpart - StrAbsimagpart i End If End If Else If Absimagpart 1 Then Label7.Caption StrAbsrealpart i Label8.Caption StrAbsrealpart -i Else If LeftStrAbsimagpart 1 . Then Label7.Caption StrAbsrealpart FormatAbsimagpart0. i Label8.Caption StrAbsrealpart - FormatAbsimagpart0. i Else Label7.Caption StrAbsrealpart StrAbsimagpart i Label8.Caption StrAbsrealpart - StrAbsimagpart i End If End If End If End If End If End IfEnd IfEnd SubPrivate Sub Command2_ClickText1.Text Text2.Text Text3.Text Label7.Caption Label8.Caption Label5.Visible TrueLabel6.Visible TrueLabel7.Visible TrueLabel8.Visible TrueLabel9.Visible FalseLabel10.Visible FalseText1.SetFocusEnd SubPrivate Sub Form_Resize 阻止用户任意改变窗体大小。
If Me.WindowState 0 Then 当窗体窗口运行时的
课件状态为正常状态时才起作用,保证最大化的正常运行。
Form1.Height 3870 Form1.Width 5880End IfEnd SubPrivate Sub Text1_KeyPressKeyAscii As Integer 使用户按回车键后光标自动跳转至 Text2。
下面的
代码的功能类似。
If KeyAscii 13 Then KeyAscii 0 避免用户按回车键后喇叭发出声响,下同。
Text2.SetFocusEnd IfEnd SubPrivate Sub Text2_KeyPressKeyAscii As IntegerIf KeyAscii 13 Then KeyAscii 0 Text3.SetFocusEnd IfEnd SubPrivate Sub Text3_KeyPressKeyAscii As Integer 用户可通过按回车键实现光标在 3 个文本框之间循环。
If KeyAscii 13 Then KeyAscii 0 Text1.SetFocusEnd IfEnd SubPrivate Sub Form_KeyDownKeyCode As Integer Shift As IntegerConst key_F1 H70 定义 F1 键,以增加
程序可读性,下同。
If KeyCode key_F1 Then 若用户按 F1 键,则执行 Command1 内的程序。
Call Command1_ClickEnd IfConst key_F2 H71If KeyCode key_F2 Then Call Command2_ClickEnd IfEnd Sub