Sub Milieu
' variables
Dim LesFeuilles as Object
Dim PremiereFeuille as Object
Dim Cellule as Object
Dim xa As String, ya As String, xb As String, String As Double
Dim xm As Double, ym As Double
'Initialisation
LesFeuilles = ThisComponent.Sheets
PremiereFeuille = LesFeuilles.GetbyName("Feuil1")
Cellule = PremiereFeuille.GetCellByPosition(2,2)
Cellule.String=""
Cellule = PremiereFeuille.GetCellByPosition(2,3)
Cellule.String=""
Cellule = PremiereFeuille.GetCellByPosition(4,2)
Cellule.String=""
Cellule = PremiereFeuille.GetCellByPosition(4,3)
Cellule.String=""
Cellule = PremiereFeuille.GetCellByPosition(2,6)
Cellule.String=""
Cellule = PremiereFeuille.GetCellByPosition(2,7)
Cellule.String=""
'Saisie des données et affichage des valeurs saisies
xa=inputbox("Donner l'abscisse du point A : ","Saisie","-5")
Cellule = PremiereFeuille.GetCellByPosition(2,2)
Cellule.String=xa
ya=inputbox("Donner l'ordonnée du point A : ","Saisie","-4")
Cellule = PremiereFeuille.GetCellByPosition(2,3)
Cellule.String=ya
xb=inputbox("Donner l'abscisse du point B : ","Saisie","2")
Cellule = PremiereFeuille.GetCellByPosition(4,2)
Cellule.String=xb
yb=inputbox("Donner l'ordonnée du point B : ","Saisie","3")
Cellule = PremiereFeuille.GetCellByPosition(4,3)
Cellule.String=yb
'Traitement
xm = (Val(xa) + Val(xb)) / 2
ym = (Val(ya) + Val(yb)) / 2
'Sortie (affichage du résultat)
Cellule = PremiereFeuille.GetCellByPosition(2,6)
Cellule.Value = xm
Cellule = PremiereFeuille.GetCellByPosition(2,7)
Cellule.Value = ym
End Sub