Probleme Mit Automatisierung

  • Excel

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von IngBello.

    Probleme Mit Automatisierung

    Hallo,

    ich will automatisirung die Code

    Sub ControlloCheckBox()
    For i = 0 To i = 10
    If CheckBox + i.Value = True Then
    out i = 8
    Else: out i = 0
    End If
    Next i
    End Sub

    aber ist nicht richtig. Ich habe 96 Checkbox in meinem Programme, und ich suche eine Lösung für nicht schreiben 96 mal die Gleich Code
    Willkommen im Forum :D

    Ich versuche, dein gebrochenes Deutsch ein bisschen zu verstehen: Du hast 96 Checkboxen und alle sollen den gleichen Code bekommen? Du könntest ja ganz einfach mit Or, AndOr oder And arbeiten udn damit ein bisschen rumbasteln. Übrigens hört sich das für mich sehr seltsam an, dass du das in VBA - Excel machst. Was genau für eine Anwendung schreibst du denn? Du könntest es ja lieber mit WPF oder eine Windows Form lösen.....

    Grüße, ExteNesia.de
    Hallo,

    danke für Antwort

    Ich Spreche nicht gut deutch aber ich versuche :D

    Die aktuale code ist:

    Private Sub CheckBox1_Click()
    If CheckBox1.Value = True Then
    teleruttore = 1
    Else: teleruttore = 0
    End If
    End Sub

    Private Sub CheckBox10_Click()
    If CheckBox10.Value = True Then
    in1 = 1
    Else: in1 = 0
    End If
    End Sub

    Private Sub CheckBox11_Click()
    If CheckBox11.Value = True Then
    in6 = 32
    Else: in6 = 0
    End If
    End Sub

    Private Sub CheckBox12_Click()
    If CheckBox12.Value = True Then
    in5 = 16
    Else: in5 = 0
    End If
    End Sub

    Private Sub CheckBox13_Click()
    If CheckBox13.Value = True Then
    in7 = 64
    Else: in7 = 0
    End If
    End Sub

    Private Sub CheckBox14_Click()
    If CheckBox14.Value = True Then
    in8 = 128
    Else: in8 = 0
    End If
    End Sub

    Private Sub CheckBox15_Click()
    If CheckBox15.Value = True Then
    in2 = 2
    Else: in2 = 0
    End If
    End Sub

    Private Sub CheckBox16_Click()
    If CheckBox16.Value = True Then
    in3 = 4
    Else: in3 = 0
    End If
    End Sub

    Private Sub CheckBox17_Click()
    If CheckBox17.Value = True Then
    in4 = 8
    Else: in4 = 0
    End If
    End Sub

    Private Sub CheckBox2_Click()
    If CheckBox2.Value = True Then
    out6 = 32
    Else: out6 = 0
    End If
    End Sub

    Private Sub CheckBox3_Click()
    If CheckBox3.Value = True Then
    out5 = 16
    Else: out5 = 0
    End If
    End Sub

    Private Sub CheckBox4_Click()
    If CheckBox4.Value = True Then
    out7 = 64
    Else: out7 = 0
    End If
    End Sub

    Private Sub CheckBox5_Click()
    If CheckBox5.Value = True Then
    out8 = 128
    Else: out8 = 0
    End If
    End Sub

    Private Sub CheckBox6_Click()
    If CheckBox6.Value = True Then
    out1 = 1
    Else: out1 = 0
    End If
    End Sub

    Private Sub CheckBox7_Click()
    If CheckBox7.Value = True Then
    out2 = 2
    Else: out2 = 0
    End If
    End Sub

    Private Sub CheckBox8_Click()
    If CheckBox8.Value = True Then
    out3 = 4
    Else: out3 = 0
    End If
    End Sub



    und Ich versuche, die Lösung:

    Sub ControlloCheckBox()
    For i = 0 To i = 10
    If Checkbox+ I.Value = True Then
    out+i = i^2
    Else: out+i = 0
    End If
    Next i
    End Sub

    aber ich Weiss nicht wenn ist eine Möglichkeit


    Ich spreche Italienisch, Französisch, Englisch und ein bisschen Deutch, sorry :D
    '---------------------------------------------
    ' nel modulo di classe di ThisWorkbook
    '---------------------------------------------

    Private Sub Workbook_Open()
    UserForm1.Show
    End Sub

    '---------------------------------------------
    ' in un modulo standard
    '---------------------------------------------

    Public Bit1 As Byte
    Public Bit2 As Byte
    Public Bit3 As Byte

    '----------------------------------------------
    ' nel modulo di classe della userform UserForm1
    '----------------------------------------------

    Dim oColEvents As Collection

    Private Sub UserForm_Initialize()
    Dim ChkbEvent As CheckBoxClass
    Dim oCtrl As Control

    Set oColEvents = New Collection

    For Each oCtrl In Me.Controls
    If TypeName(oCtrl.Object) = "IMdcCheckBox" Then
    Set ChkbEvent = New CheckBoxClass
    Set ChkbEvent.mCheckboxes = oCtrl
    oColEvents.Add ChkbEvent, oCtrl.Name
    Set ChkbEvent = Nothing
    End If
    Next
    End Sub

    '----------------------------------------------
    ' nel modulo di classe CheckBoxClass
    '----------------------------------------------

    Public WithEvents mCheckboxes As MSForms.CheckBox

    Private Sub mCheckboxes_Click()
    Bit1 = -UserForm1.ChkB1.Value
    Bit2 = -UserForm1.ChkB2.Value
    Bit3 = -UserForm1.ChkB3.Value
    MsgBox " Bit 1" & vbTab & "Bit 2" & vbTab & "Bit 3" & vbCrLf & _
    " " & Bit1 & vbTab & " " & Bit2 & vbTab & " " & Bit3
    Debug.Print 1 * Bit1 + 10 * Bit2 + 100 * Bit3
    End Sub


    Ich denke ist eine gute Idea