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

📄 例2-29.frm

📁 Visual Basic程序设计基础》-杨小影-源代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.PictureBox Picture1 
      Height          =   735
      Left            =   480
      ScaleHeight     =   675
      ScaleWidth      =   3675
      TabIndex        =   6
      Top             =   2040
      Width           =   3735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "求解"
      Height          =   615
      Left            =   3720
      TabIndex        =   5
      Top             =   1080
      Width           =   855
   End
   Begin VB.TextBox Text2 
      Height          =   615
      Left            =   2640
      TabIndex        =   4
      Top             =   1080
      Width           =   615
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   1080
      TabIndex        =   3
      Top             =   1140
      Width           =   615
   End
   Begin VB.Label Label3 
      Caption         =   "n:"
      Height          =   495
      Left            =   2160
      TabIndex        =   2
      Top             =   1140
      Width           =   615
   End
   Begin VB.Label Label2 
      Caption         =   "a:"
      Height          =   495
      Left            =   600
      TabIndex        =   1
      Top             =   1140
      Width           =   495
   End
   Begin VB.Label Label1 
      Caption         =   "请依次输入a和n的值:"
      Height          =   375
      Left            =   600
      TabIndex        =   0
      Top             =   240
      Width           =   2535
   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()
Dim i As Integer
Dim a As Double, b As Double, tn As Double, sn As Double
Picture1.Cls
i = 1: tn = 0: sn = 0
a = Val(Text1.Text)
b = a
If Val(Text1.Text) > 0 And Val(Text1.Text) < 10 And Val(Text2.Text) > 2 Then
   Do While (i <= CInt(Text2.Text))
      tn = tn + a
      sn = sn + tn
      a = a * 10
      i = i + 1
   Loop
Else
   MsgBox "请输入10以内的自然数!", vbOKOnly + vbInformation, "数据错误"
End If
Picture1.Print b & "+" & b & b & "+..." & "+"; tn & " = "; sn
End Sub

⌨️ 快捷键说明

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