DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
'Lermite222
'3/12/2010
Option Explicit
'------------------------------------
'Déclaration des collections
Dim CollectBouton As Collection
Dim ClGroup As Collection
'------------------------------------
'Déclaration pour les instances de classe
Dim mBouton As Cl_Bouton
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
ControlClick 11
End If
End Sub
Private Sub UserForm_Initialize()
Dim Ctl As Control
'--------------------------------------------------------
'Crée les collections de classe
Set CollectBouton = New Collection
'--------------------------------------------------------
'Crée la collection d'objet
Set ClGroup = New Collection
'--------------------------------------------------------
For Each Ctl In Me.Controls
'verifie s'il s'agit d'un bouton
If TypeOf Ctl Is MSForms.CommandButton Then
'ajoute dans la collection des classes boutons
Set mBouton = New Cl_Bouton
Set mBouton.GroupBoutons = Ctl
CollectBouton.Add mBouton
'ajoute dans la collection des Objets ClGroup et initialise sa clé
ClGroup.Add Ctl, Ctl.Tag
End If
Next Ctl
End Sub
Public Sub ControlClick(Index As Integer)
Select Case Index
Case Is < 10: AjouterSurText CStr(Index)
Case Is = 10: AjouterSurText ","
Case Is = 11 'Résultat
On Error GoTo ErreurCalcul
Label1.Caption = Evaluate(Replace(TextBox1.Text, ",", "."))
Case Is < 18
AjouterSurText ClGroup(CStr(Index)).Caption
Case 18: If TextBox1.SelLength > 0 Then AjouterSurText ""
Case 19: TextBox1 = "": Label1 = ""
End Select
Exit Sub
ErreurCalcul:
MsgBox "Votre calcul comporte une erreur", vbCritical, "Calculatrice"
End Sub
Sub AjouterSurText(T As String)
If Len(TextBox1.Text) = TextBox1.SelStart Then 'Ajoute
TextBox1 = TextBox1 & T
Else 'Insertion / remplacement
TextBox1 = Left(TextBox1, TextBox1.SelStart) & T _
& Mid(TextBox1, TextBox1.SelStart + 1 + TextBox1.SelLength)
End If
TextBox1.SetFocus
End Sub
ption Explicit
Public WithEvents GroupBoutons As MSForms.CommandButton
Private Sub GroupBoutons_Click()
Call UFCalculatrice.ControlClick(GroupBoutons.Tag)
End Sub
Private Sub CmdCalcul_Click()
UFCalculatrice.Show
End Sub
şurada hazır bir hesap makinesi var:
http://en.kioskea.net/faq/10860-excel-vba-calculator
dosyayı indirmek mümkün ve kodlar açık kod...