09.08.2020, 09:34
Naja habe gestern irgendwas geändert und ist ja auch nur Spielerei. Aber wie kann das sein? Also meinst du der Code an sich funktioniert, wenn uvb die UserForm1 einfach neu anlege?
Private Sub CommandButton1_Click()Gruß Uwe
Dim bolText As Boolean
Dim oControl As Control
For Each oControl In Me.Controls
If TypeName(oControl) = "TextBox" Then
bolText = Len(oControl)
If Not bolText Then Exit For
End If
Next oControl
If bolText Then
MsgBox "Messagebox1"
Else
MsgBox "Messagebox2"
End If
End Sub
Private Sub CommandButton1_Click()Gruß Uwe
Dim bolText As Boolean
Dim oControl As Control
For Each oControl In Me.Controls
If TypeName(oControl) = "TextBox" Then
bolText = Len(oControl)
If Not bolText Then Exit For
End If
Next oControl
If bolText Then
If MsgBox("Messagebox1", vbYesNo + vbQuestion) = vbYes Then
CodeBeiKeineLeer
End If
Else
If MsgBox("Messagebox2", vbYesNo + vbQuestion) = vbYes Then
CodeBeiLeer
End If
End If
End Sub
Sub CodeBeiLeer()
MsgBox "Mindestens eine TextBox ist leer"
End Sub
Sub CodeBeiKeineLeer()
MsgBox "Keine TextBox ist leer"
End Sub
Private Sub inspectionlot()
Application.ScreenUpdating = False
Dim Interval As String
Dim result As Integer
result = Range("BA10").Value * (CDbl(TextBox_Interval.Value) / 100)
If TextBox_Interval.Value = "" Then Exit Sub
If TextBox_Interval.Value < 100 Then
Interval = "Prüfintervall " & TextBox_Interval.Value & "%, jedes " & CVar(result) & ". Teil."
ElseIf TextBox_Interval.Value = 100 Then
Interval = "Prüfintervall " & TextBox_Interval.Value & "%, jedes Teil."
End If
Range("B41:BH41").Select
ActiveCell.Value = CVar(Interval)
Range("A1").Select
Application.ScreenUpdating = True
End Sub
Sub allcompleted()
MsgBox "Mit OK werden alle Eingaben übernommen." & vbCrLf & "Vorhandener Inhalt wird überschrieben!"
ActiveSheet.Range("B3") = TextBox_Customer.Value
ActiveSheet.Range("BA6") = TextBox_Date.Value
ActiveSheet.Range("BF6") = TextBox_Version.Value
ActiveSheet.Range("L7") = TextBox_PartNo.Value
ActiveSheet.Range("AG7") = TextBox_JobNo.Value
ActiveSheet.Range("BA7") = TextBox_TestplanNo.Value
ActiveSheet.Range("L9") = TextBox_DrawingNo.Value
ActiveSheet.Range("AD9") = TextBox_Index.Value
ActiveSheet.Range("AR9") = TextBox_PartName.Value
ActiveSheet.Range("L10") = TextBox_OrderNo.Value
ActiveSheet.Range("AG10") = TextBox_CommissionNo.Value
ActiveSheet.Range("BA10") = TextBox_Pieces.Value
ActiveSheet.Range("L11") = TextBox_Operation.Value
ActiveSheet.Range("AR11") = TextBox_Machine.Value
ActiveSheet.Range("L12") = TextBox_Material.Value
ActiveSheet.Range("BJ1") = TextBox_Interval.Value
'ActiveSheet.Range("BA5") = TextBox_Creator.Value
Call inspectionlot
End Sub
Sub notallcompleted()
MsgBox "Es wurden nicht alle Eingaben gemacht." & Chr(13) & "Mit OK werden alle Eingaben und leere Textfelder übernommen!"
ActiveSheet.Range("B3") = TextBox_Customer.Value
ActiveSheet.Range("BA6") = TextBox_Date.Value
ActiveSheet.Range("BF6") = TextBox_Version.Value
ActiveSheet.Range("L7") = TextBox_PartNo.Value
ActiveSheet.Range("AG7") = TextBox_JobNo.Value
ActiveSheet.Range("BA7") = TextBox_TestplanNo.Value
ActiveSheet.Range("L9") = TextBox_DrawingNo.Value
ActiveSheet.Range("AD9") = TextBox_Index.Value
ActiveSheet.Range("AR9") = TextBox_PartName.Value
ActiveSheet.Range("L10") = TextBox_OrderNo.Value
ActiveSheet.Range("AG10") = TextBox_CommissionNo.Value
ActiveSheet.Range("BA10") = TextBox_Pieces.Value
ActiveSheet.Range("L11") = TextBox_Operation.Value
ActiveSheet.Range("AR11") = TextBox_Machine.Value
ActiveSheet.Range("L12") = TextBox_Material.Value
ActiveSheet.Range("BJ1") = TextBox_Interval.Value
'ActiveSheet.Range("BA5") = TextBox_Creator.Value
Call inspectionlot
End Sub
Private Sub CMD_Apply_Click()
If TextBox_Interval.Value = "" Then Range("B41:BH41").ClearContents
If TextBox_Interval.Value = "" Then
End If
Dim bolText As Boolean
Dim oControl As Control
For Each oControl In Me.Controls
If TypeName(oControl) = "TextBox" Then
bolText = Len(oControl)
If Not bolText Then Exit For
End If
Next oControl
If bolText Then
If MsgBox("Mit OK werden alle Eingaben übernommen." & vbCrLf & "Vorhandener Inhalt wird überschrieben!", vbOKCancel + vbExclamation) = vbYes Then
allcompleted
End If
Else
If MsgBox("Es wurden nicht alle Eingaben gemacht." & vbCrLf & "Mit OK werden alle Eingaben und leere Textfelder übernommen!", vbOKCancel + vbExclamation) = vbYes Then
notallcompleted
End If
End If
End Sub