VB六个数取最大值和平均数的平方

VERSION 5.00
Begin VB.Form Form2
   AutoRedraw      =   -1  'True
   Caption         =   "计算界面"
   ClientHeight    =   4905
   ClientLeft      =   4965
   ClientTop       =   3630
   ClientWidth     =   5715
   LinkTopic       =   "Form2"
   ScaleHeight     =   4905
   ScaleWidth      =   5715
   Begin VB.CommandButton Command1
      Caption         =   "计算"
      Height          =   495
      Left            =   2520
      TabIndex        =   11
      Top             =   240
      Width           =   1335
   End
   Begin VB.CommandButton Command2
      Caption         =   "清空"
      Height          =   495
      Left            =   4320
      TabIndex        =   12
      Top             =   240
      Width           =   1095
   End
   Begin VB.TextBox Text8
      Height          =   615
      Left            =   4440
      TabIndex        =   10
      Top             =   3600
      Width           =   1095
   End
   Begin VB.TextBox Text7
      Height          =   615
      Left            =   1920
      TabIndex        =   8
      Top             =   3600
      Width           =   975
   End
   Begin VB.TextBox Text6
      Height          =   615
      Left            =   3960
      TabIndex        =   6
      Top             =   2160
      Width           =   1215
   End
   Begin VB.TextBox Text5
      Height          =   615
      Left            =   2280
      TabIndex        =   5
      Top             =   2160
      Width           =   1095
   End
   Begin VB.TextBox Text4
      Height          =   735
      Left            =   600
      TabIndex        =   4
      Top             =   2040
      Width           =   1215
   End
   Begin VB.TextBox Text3
      Height          =   735
      Left            =   3960
      TabIndex        =   3
      Top             =   1080
      Width           =   1215
   End
   Begin VB.TextBox Text2
      Height          =   615
      Left            =   2280
      TabIndex        =   2
      Top             =   1080
      Width           =   1095
   End
   Begin VB.TextBox Text1
      Height          =   615
      Left            =   600
      TabIndex        =   1
      Top             =   1080
      Width           =   1215
   End
   Begin VB.Label Label3
      Caption         =   "六个数的平均数的平方:"
      Height          =   615
      Left            =   3240
      TabIndex        =   9
      Top             =   3600
      Width           =   855
   End
   Begin VB.Label Label2
      Caption         =   "六个数中的最大值:"
      Height          =   495
      Left            =   480
      TabIndex        =   7
      Top             =   3600
      Width           =   1095
   End
   Begin VB.Label Label1
      Caption         =   "请输入六个自然数:"
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   240
      Width           =   1695
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Function Max(Arr As Variant)
Max = Arr(0)
For i = 0 To UBound(Arr)
If Arr(i) > Max Then Max = Arr(i)
Next
End Function

Private Sub Command1_Click()
Arr = Array(Text1.Text, Text2.Text, Text3.Text, Text4.Text, Text5.Text, Text6.Text)
Text7.Text = Max(Arr)


Text8.Text = Str$(((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)) * (Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text))) / Val(36))

 


End Sub

 

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值