Private Sub Cmdline_Click()
CDialog.ShowColor
For i = 0 To 3
ln(i).BorderColor = CDialog.Color
Next i
End Sub
Private Sub Cmdsfondo_Click()
CDialog.ShowColor
Me.BackColor = CDialog.Color
End Sub
Private Sub Form_DblClick()
Form_Load
Me.Refresh
End Sub
Private Sub Form_Load()
Me.Caption = "Disegna un triangolo"
b.Visible = True
h.Visible = True
Label1.Visible = True
Label2.Visible = True
ok.Visible = True
Cmdsfondo.Visible = False
Cmdline.Visible = False
spess.Visible = False
For i = 0 To 19
spess.AddItem i + 1
If i < 4 Then ln(i).Visible = False
Next i
End Sub
Private Sub ok_Click()
If IsNumeric(b.Text) = False Then GoTo nob
If IsNumeric(h.Text) = False Then GoTo noh
b = b.Text
h = h.Text
If b <= 0 Or b > Me.Width Then GoTo tb
If h <= 0 Or h > Me.Height Then GoTo th
b.Visible = False
h.Visible = False
Label1.Visible = False
Label2.Visible = False
ok.Visible = False
Cmdsfondo.Visible = True
Cmdline.Visible = True
spess.Visible = True
'coordinate degli angoli del triangolo
xb1 = (Me.Width - b) / 2
xb2 = xb1 + b
xh = Me.Width / 2
yh1 = (Me.Height - h) / 2
yh2 = yh1 + h
Me.DrawWidth = 2
'altezza
ln(0).X1 = xh
ln(0).Y1 = yh1
ln(0).X2 = xh
ln(0).Y2 = yh2
'base
ln(1).X1 = xb1
ln(1).Y1 = yh2
ln(1).X2 = xb2
ln(1).Y2 = yh2
'lati
ln(2).X1 = xh
ln(2).Y1 = yh1
ln(2).X2 = xb2
ln(2).Y2 = yh2
ln(3).X1 = xb1
ln(3).Y1 = yh2
ln(3).X2 = xh
ln(3).Y2 = yh1
For i = 0 To 3
ln(i).Visible = True
Next i
Me.Caption = "DblCclick per disegnare un altro triangolo"
Exit Sub
nob:
MsgBox "Inserisci valore numerico", vbCritical, "Tipo non corrispondente"
b.Text = ""
Exit Sub
noh:
MsgBox "Inserisci valore numerico", vbCritical, "Tipo non corrispondente"
h.Text = ""
Exit Sub
tb:
MsgBox "Inserisci un nuemro > di 0 e < o = a " & Me.Width & Chr(13) & Chr(10) & "Puoi anche ingrandire la finestra", vbCritical, "Errore"
b.Text = ""
Exit Sub
th:
MsgBox "Inserisci un nuemro > di 0 e < o = a " & Me.Height & Chr(13) & Chr(10) & "Puoi anche ingrandire la finestra", vbCritical, "Errore"
h.Text = ""
End Sub
Private Sub spess_Click()
For i = 0 To 3
ln(i).BorderWidth = spess.Text
Next i
End Sub