Oppure

Loading
26/01/10 10:10
maurizio74
Ciao Alfonso scusa se ti rompo ancora...
tutti i number funzionano perfettamente ho fatto la stessa cosa con gli operatori e mi da errore... questo era il codice...

Private Sub Number_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
TastoGiu Index
End Sub
Private Sub TastoGiu(Index As Integer)
number(Index).Picture = Imagegiu(Index).Picture
operator(Index).Picture = Imagegiu(Index).Picture
End Sub
Private Sub TastoSu(Index As Integer)
number(Index).Picture = Imagesu(Index).Picture
operator(Index).Picture = Imagesu(Index).Picture
End Sub
aaa
26/01/10 10:59
Alfonso
Immagino che l'errore sia L'elemento "x" della matrice non esiste.

L'indice dei controlli operator va da 0 a 4.

Per cui se premi un numero > 4 per es 7
in Number_MouseDown l'index (che è 7) viene trasmesso a TastoGiu Index e in

Private Sub TastoGiu(Index As Integer)
Number(Index).Picture = ImageGiu(Index).Picture
operator(Index).Picture = ImageGiu(Index).Picture
End Sub

operator(Index).Picture da errore perche operator(7) non esiste!

La cosa più semplice è togliere l'istruzione da TastoGiu e creare una

Private Sub TastoGiuOperatore(Index As Integer)
operator(Index).Picture = ImageGiu(Index).Picture
End Sub

e modificare operator_MouseDown in modo che richiami TastoGiuOperatore
E poi come l'hai scritto premendo il + (indice=1) cambia anche l'immagine del numero 1
aaa
26/01/10 11:37
maurizio74
ok prima che tu mi rispondessi c'ero arrivato con alcuni tentativi infatti l'avevo sistemato...
l'unico problema e che non mi fa le operazioni e non capisco perche'????
aaa
26/01/10 11:59
Alfonso
La mia copia funziona e siccome non ho la sfera di cristallo...
Allega il Calc.frm, altrimenti non posso sapere cosa hai scritto e come l'hai scritto. :-o
aaa
26/01/10 12:11
maurizio74
Il problema sara' suicuramente qui: negli operatori manca qualcosa???


Private Sub Operator_Click(Index As Integer)
Text1.SetFocus
TempReadout = Readout
If LastInput = "NUM" Then
NumOps = NumOps + 1
End If
Select Case NumOps
Case 0
If operator(Index) = "-" And LastInput <> "NEG" Then
Readout = "-" & Readout
LastInput = "NEG"
End If
Case 1
Op1 = Readout
If operator(Index) = "-" And LastInput <> "NUM" And OpFlag <> "=" Then
Readout = "-"
LastInput = "NEG"
End If
Case 2
Op2 = TempReadout
Select Case OpFlag
Case "+"
Op1 = CDbl(Op1) + CDbl(Op2)
Case "-"
Op1 = CDbl(Op1) - CDbl(Op2)
Case "*"
Op1 = CDbl(Op1) * CDbl(Op2)
Case "/"
If Op2 = 0 Then
MsgBox "Impossibile dividere per zero", 48, "Calcolatrice"
Else
Op1 = CDbl(Op1) / CDbl(Op2)
End If
Case "="
Op1 = CDbl(Op2)
Case "%"
Op1 = CDbl(Op1) * CDbl(Op2)
End Select
Readout = Op1
NumOps = 1
End Select
If LastInput <> "NEG" Then
LastInput = "OP"
OpFlag = operator(Index)
End If
End Sub
aaa
26/01/10 13:08
Alfonso
Avevi detto di aver tolto la caption ai tasti per farci stare le immagini.

Allora quello che prima era:

If operator(Index).Caption = "-" And LastInput <> "NEG" Then

tu lo hai cambiato in

If operator(Index) = "-" And LastInput <> "NEG" Then

ma operator(Index) = "-" dà come risultato Falso perchè visual basic se non è indicata nessuna proprietà sottintende sempre quella di default

Allora se togli le caption devi sostituire il riferimento alla caption (che non esiste più;) con per esempio il tag.

Per cui

If operator(Index).Caption = "-" diventa
If operator(Index).Tag = "-"

OpFlag = operator(Index).Tag

e inserire nei tasti operator il tag uguale a quello che prima era il caption.

operator(0).tag = "="
operator(1).tag = "+"
.........
aaa
26/01/10 14:13
maurizio74
Ti ringrazio ancora per le dritte io non sapevo nemmeno che il tag poteva sostiture il caption!!! grazie ancora...
aaa
26/01/10 14:22
Alfonso
Il tag di un controllo non è altro che un "deposito" di quel controllo dove tu puoi scrivere qualsiasi cosa, numeri o stringhe e leggerle in seguito con variabile=controllo.tag
aaa