'楼主您好!
'在窗体上画一个按钮,一个文本框
'代码如下:
Option Explicit
Dim intNumber1 As Long, intNumber2 As Long, intNumber3 As Long
Private Sub Command1_Click()
If IsNumeric(Text1.Text) = False Then
MsgBox "错误,请输入一个数值!", 16 + vbOKCancel + vbDefaultButton1, "错误报告"
Exit Sub
ElseIf Len(Text1.Text) > 3 Then
MsgBox "错误,请输入一个三位数!", 16 + vbOKCancel + vbDefaultButton1, "错误报告"
Exit Sub
Else
intNumber1 = Val(Mid(Text1.Text, 1, 1))
intNumber2 = Val(Mid(Text1.Text, 2, 1))
intNumber3 = Val(Mid(Text1.Text, 3, 1))
MsgBox "百位数为:" intNumber1 ",百位数的立方为:" intNumber1 ^ 3 vbCrLf _
"十位数为:" intNumber2 ",十位数的立方为:" intNumber2 ^ 3 vbCrLf _
"个位个数为:" intNumber3 ",个位个数的立方为:" intNumber3 ^ 3 vbCrLf _
"三个数的立方和为:" intNumber1 ^ 3 + intNumber2 ^ 3 + intNumber3 ^ 3 _
, 64 + vbOKCancel + vbDefaultButton1, "计算结果"
End If
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Su