
Option Explicit Sub Egitto() Dim Base As Double, Altezza As Double, Volume As Double Base = 10 Altezza = 10 Volume = (Base ^ 2 * Altezza) / 3 End Sub |
Option Explicit
Sub piramide()
Dim a As Variant, h As Variant, vol As Single
Application.ScreenUpdating = False
1:
a = InputBox("Inserisci lunghezza base della piramide")
If Not IsNumeric(a) Then
MsgBox "Inserire un numero"
GoTo 1:
End If
2:
h = InputBox("Ora inserisci anche l'altezza")
If Not IsNumeric(h) Then
MsgBox "Inserire un numero"
GoTo 2:
End If
vol = Val(a) * Val(h) / 3
MsgBox " il volume della tua piramide è di " & vol & " !!!"
End Sub
|
'Sostituisci: vol = Val(a) * Val(h) / 3 con vol = Val(a^2) * Val(h) / 3 |
Option Explicit
Sub Egitto()
Dim Base As Double, Altezza As Double, Volume As Double
Base = Application.InputBox("Base", Type:=1)
Altezza = Application.InputBox("Altezza", Type:=1)
Volume = MsgBox("Volume: " & (Base ^ 2 * Altezza) / 3)
End Sub
|
