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

📄 解方程实根.frm

📁 Visual Basic课程举例1 有很好的例题
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "计算一元二次方程的程序例子"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   3480
      TabIndex        =   7
      Top             =   840
      Width           =   495
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   2400
      TabIndex        =   6
      Top             =   840
      Width           =   495
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   960
      TabIndex        =   5
      Top             =   840
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "计   算"
      Height          =   375
      Left            =   840
      TabIndex        =   0
      Top             =   2520
      Width           =   3015
   End
   Begin VB.Label Label6 
      Caption         =   "x2="
      Height          =   255
      Left            =   1200
      TabIndex        =   9
      Top             =   1920
      Width           =   2055
   End
   Begin VB.Label Label5 
      Caption         =   "x1="
      Height          =   255
      Left            =   1200
      TabIndex        =   8
      Top             =   1560
      Width           =   1815
   End
   Begin VB.Label Label4 
      Caption         =   "输入c"
      Height          =   255
      Left            =   2880
      TabIndex        =   4
      Top             =   900
      Width           =   615
   End
   Begin VB.Label Label3 
      Caption         =   "输入b"
      Height          =   255
      Left            =   1920
      TabIndex        =   3
      Top             =   900
      Width           =   615
   End
   Begin VB.Label Label2 
      Caption         =   "输入a"
      Height          =   255
      Left            =   480
      TabIndex        =   2
      Top             =   900
      Width           =   615
   End
   Begin VB.Label Label1 
      Caption         =   "计算a*x^2+b*x+c=0"
      Height          =   255
      Left            =   1560
      TabIndex        =   1
      Top             =   360
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    '计算a*x^2+b*x+c=0 的两个根
    Dim a As Integer, b As Integer, c As Integer
    Dim x1 As Single, x2 As Single, d As Single
    a = Text1.Text
    b = Text2
    c = Text3
    d = b * b - 4 * a * c  '计算△
    If d >= 0 Then
        x1 = (-b + Sqr(d)) / (2 * a)
        x2 = (-b - Sqr(d)) / (2 * a)
        Label5.Caption = Label5.Caption & Format(x1, "###.##")
        Label6.Caption = Label6.Caption & Format(x2, "###.##")
    End If
End Sub

⌨️ 快捷键说明

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