MaikBisschop
Gebruiker
- Lid geworden
- 19 mrt 2018
- Berichten
- 39
Beste forumleden,
Ik heb een gedeelte code geschreven dat bestaat variabelen en voorwaarden. De code werkt, maar zou graag weten of dit bepaalde
deel nog simpeler zou kunnen . Het gaat om het onderstaande deel.
CB = CheckBox ( Belangrijk dat de waarde 'True/False' blijft, wanneer deze '1/0' wordt gaat dit waarschijnlijk voor problemen zorgen
LB = ListBox
TB = TextBox
CBN = CommandButton
Graag hoor ik jullie ideën / aanvullingen!
Met vriendelijk groet,
Maik Bisschop
Ik heb een gedeelte code geschreven dat bestaat variabelen en voorwaarden. De code werkt, maar zou graag weten of dit bepaalde
deel nog simpeler zou kunnen . Het gaat om het onderstaande deel.
Code:
Private Sub Variables_And_Conditions()
'Variables
If Len(Me.TB1.Text) > 1 Then M1 = 1 Else M1 = 0
If Len(Me.TB2.Text) > 1 Then M2 = 1 Else M2 = 0
If CB1 = True Then M3 = 1 Else M3 = 0
If CB2 = True Then M4 = 1 Else M4 = 0
If CB3 = True Then M5 = 1 Else M5 = 0
If CB4 = True Then M6 = 1 Else M6 = 0
If CB5 = True Then M7 = 1 Else M7 = 0
If CB6 = True Then M8 = 1 Else M8 = 0
If CB7 = True Then M9 = 1 Else M9 = 0
If LB1.ListIndex >= 0 Then M10 = 1 Else M10 = 0
If LB2.ListIndex >= 0 Then M11 = 1 Else M11 = 0
'Conditions
If M1 = 1 And M2 = 1 And M10 = 1 And M11 = 1 Then CBN2.Enabled = 1 Else CBN2.Enabled = 0
If M3 = 1 Then TB1.Enabled = 1 And TB1.Locked = 0 Else TB1.Enabled = 0 And TB1.Locked = 1 And TB1.Value = ("American projection")
If M3 = 1 Then sheet1.Range("D14").Value = "(Custom)" Else sheet1.Range("D14").Value = "(Standard)"
If M3 = 1 Then sheet1.Range("D13").Value = TB1.Value
If M4 = 1 Then TB2.Enabled = 1 And TB2.Locked = 0 Else TB2.Enabled = 0 And TB2.Locked = 1 And TB2.Value = ("English")
If M4 = 1 Then sheet1.Range("D17").Value = "(Custom)" Else sheet1.Range("D17").Value = "(Standard)"
If M4 = 1 Then sheet1.Range("D16").Value = TB2.Value
If M5 = 1 Then sheet1.Range("D20").Value = "PDF " + ChrW(&H2713) Else sheet1.Range("D20").Value = "PDF " + ChrW(&H2715)
If M6 = 1 Then sheet1.Range("D21").Value = "DXF " + ChrW(&H2713) Else sheet1.Range("D21").Value = "DXF " + ChrW(&H2715)
If M7 = 1 Then sheet1.Range("D22").Value = "DWG " + ChrW(&H2713) Else sheet1.Range("D22").Value = "DWG " + ChrW(&H2715)
If M8 = 1 Then sheet1.Range("F20").Value = "PDF " + ChrW(&H2713) Else sheet1.Range("F20").Value = "PDF " + ChrW(&H2715)
If M9 = 1 Then sheet1.Range("F21").Value = "STEP " + ChrW(&H2713) Else sheet1.Range("F21").Value = "STEP " + ChrW(&H2715)
If M10 = 0 Then L10.Caption = "None" And L11.Caption = "None"
If M10 = 1 Then L10.Caption = LB1.Value And L11.Caption = LB2.Value
If M10 = 1 Then LB2.Enabled = 1 And LB2.Locked = 0 Else LB2.Enabled = 0 And LB2.Locked = 1
If M11 = 0 Then L11.Caption = "None"
If M11 = 1 Then L11.Caption = LB2.Value
End Sub
Private Sub UserForm_Initialize()
Dim M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11 As Boolean
LB1.List = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
LB2.List = Array("A0", "A1", "A2", "A3", "A4")
If sheet1.Range("D20").Value = "PDF " + ChrW(&H2713) Then CB3.Value = True Else CB3.Value = False
If sheet1.Range("D21").Value = "DXF " + ChrW(&H2713) Then CB4.Value = True Else CB4.Value = False
If sheet1.Range("D22").Value = "DWG " + ChrW(&H2713) Then CB5.Value = True Else CB5.Value = False
If sheet1.Range("F20").Value = "PDF " + ChrW(&H2713) Then CB6.Value = True Else CB6.Value = False
If sheet1.Range("F21").Value = "STEP " + ChrW(&H2713) Then CB7.Value = True Else CB7.Value = False
If sheet1.Range("D20").Value = "PDF " + ChrW(&H2713) Then CB3.Value = True Else CB3.Value = False
If sheet1.Range("D21").Value = "DXF " + ChrW(&H2713) Then CB4.Value = True Else CB4.Value = False
If sheet1.Range("D22").Value = "DWG " + ChrW(&H2713) Then CB5.Value = True Else CB5.Value = False
If sheet1.Range("F20").Value = "PDF " + ChrW(&H2713) Then CB6.Value = True Else CB6.Value = False
If sheet1.Range("F21").Value = "STEP " + ChrW(&H2713) Then CB7.Value = True Else CB7.Value = FalseVariables_And_Conditions
End Sub
CB = CheckBox ( Belangrijk dat de waarde 'True/False' blijft, wanneer deze '1/0' wordt gaat dit waarschijnlijk voor problemen zorgen
LB = ListBox
TB = TextBox
CBN = CommandButton
Graag hoor ik jullie ideën / aanvullingen!

Met vriendelijk groet,
Maik Bisschop
Laatst bewerkt: