2° L'errore principale che commetti è che viene eseguito del codice anche se i campi dei dati sono vuoti. Invece, in questo caso, devi uscire dalla routine, così:
Ho eseguito come hai detto tu, ora non mi crea l'errore, però a sua volta non vi avvisa che il valore Saetta è <= 8, insomma non parte la Msgbox di avviso.
Io l'ho inserito così:
codice:
Private Sub command1_click()
If Conicità.Text = "" Or Altezza.Text = "" Or Corda.Text = "" Then
MsgBox "Inserire Conicità,Altezza e Corda", vbInformation, "ERRORE"
Else
Tangente.Caption = Conicità.Text / Altezza.Text
Arcotangente.Caption = Atn(Tangente.Caption)
Seno.Caption = Sin(Arcotangente.Caption)
Cateto.Text = Corda.Text / 2
Ipotenusa.Text = Cateto / Seno
Dim Cateto2 As Double
Cateto2 = Sqr(Ipotenusa.Text ^ 2 - Cateto ^ 2)
Saetta.Text = Ipotenusa.Text - Cateto2
Raggio.Text = (Corda ^ 2 / (4 * Saetta) + Saetta) / 2
Exit Sub
End If
If Saetta.Text <= 8 Then
MsgBox "Inserire nuova corda(Corda2)", vbInformation, "ERRORE"
Else
Dim Cateto3 As Double
Cateto3 = Sqr(Ipotenusa.Text ^ 2 - (Corda2.Text / 2) ^ 2)
Saetta2.Text = Ipotenusa.Text - Cateto3
End If
End Sub