⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 解方程所有根.frm

📁 Visual Basic课程举例1 有很好的例题
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3720
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5220
   LinkTopic       =   "Form1"
   ScaleHeight     =   3720
   ScaleWidth      =   5220
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text3 
      Height          =   495
      Left            =   3240
      TabIndex        =   9
      Top             =   720
      Width           =   615
   End
   Begin VB.TextBox Text2 
      Height          =   495
      Left            =   1920
      TabIndex        =   8
      Top             =   720
      Width           =   615
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   480
      TabIndex        =   7
      Top             =   720
      Width           =   615
   End
   Begin VB.CommandButton CmdCalcu 
      Caption         =   "计算&c"
      Height          =   615
      Left            =   1440
      TabIndex        =   0
      Top             =   2820
      Width           =   2295
   End
   Begin VB.Label Label6 
      Caption         =   "C="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2880
      TabIndex        =   6
      Top             =   840
      Width           =   375
   End
   Begin VB.Label Label5 
      Caption         =   "B="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1560
      TabIndex        =   5
      Top             =   840
      Width           =   375
   End
   Begin VB.Label Label4 
      Caption         =   "A="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   840
      Width           =   375
   End
   Begin VB.Label Label3 
      Caption         =   "x2="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   600
      TabIndex        =   3
      Top             =   2220
      Width           =   3375
   End
   Begin VB.Label Label2 
      Caption         =   "x1="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   600
      TabIndex        =   2
      Top             =   1680
      Width           =   3315
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "ax*x+bx+c=0"
      BeginProperty Font 
         Name            =   "Script"
         Size            =   21.75
         Charset         =   255
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1440
      TabIndex        =   1
      Top             =   120
      Width           =   1740
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCalcu_Click()
    Dim a As Single, b As Single, c As Single
    Dim D As Single
    Dim x1 As Single, x2 As Single, x As Single
    a = Text1
    b = Text2
    c = Text3
    If a = 0 Then
        x = -c / b
        Label2.Caption = Label2.Caption + Format(x)
        Label3.Caption = Label3.Caption + Format(x)
    Else
        D = b * b - 4 * a * c
        If D >= 0 Then
            If D > 0 Then
                x1 = (-b + Sqr(D)) / (2 * a)
                x2 = (-b - Sqr(D)) / (2 * a)
                Label2.Caption = Label2.Caption + Format(x1)
                Label3.Caption = Label3.Caption + Format(x2)
            Else
                x = -b / (2 * a)
                Label2.Caption = Label2.Caption + Format(x)
                Label3.Caption = Label3.Caption + Format(x)
            End If
        Else
            D = Abs(D)
            x1 = (-b) / (2 * a)
            x2 = Sqr(D) / (2 * a)
            Label2.Caption = Label2.Caption + Format(x1, "##.##") + _
            "+" + Format(Abs(x2), "##.##") + " i "
            Label3.Caption = Label3.Caption + Format(x1, "##.##") + _
            "-" + Format(Abs(x2), "##.##") + " i "
        End If
    End If
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -