Dim sconto As Single, valore As Single
Dim i As Integer, j As Integer, num As Single, flag As Boolean
Private Sub cmddel_Click()
Text1.Text = ""
Form1.Height = 1650
lblsconto.Caption = ""
Text1.SetFocus
End Sub
Private Sub Command1_Click()
If Text1.Text <> "" Then
If IsNumeric(Text1.Text) Then
Form1.Height = 2535
num = CSng(Text1.Text)
sconto = CSng(Mid(Combo1.Text, 1, 2))
sconto = num * sconto / 100
valore = Round(num - sconto, 2)
lblsconto.Caption = "Il prezzo è : " & valore
Else
Text1.Text = ""
Text1.SetFocus
End If
Else
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Form1.Height = 1650
j = -1
For i = 10 To 95 Step 5
j = j + 1
Combo1.List(j) = i & "%"
Next i
Combo1.Text = "50%"
End Sub
Private Sub Text1_Change()
If flag Then
flag = False
Text1.Text = ""
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(",") Then
Exit Sub
End If
If KeyAscii = 46 Or (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) Then
MsgBox "Input errato", vbInformation, "Errore"
flag = True
End If
End Sub