Option Explicit Private Sub cmdCancel_Click() frmJob.Hide 'myCancelled bleibt also auf startwert (true) End Sub Private Sub cmdOK_Click() frmJob.Hide ' form auf jeden fall schon mal ausknipsen If [Days] < [Daysforchange] Then MsgBox "Geht nicht - Umstellzeit wäre länger als diese Kampagne! " Exit Sub ' also so dass mycancelled immer noch auf true bleibt! End If If frmJob.ListBox1.ListIndex <= 0 Then Exit Sub If [PNum] = [PreNum] Then Exit Sub ' erst wenn alle prüfungen überstanden, mycancelled auf false setzen.... myCancelled = False End Sub Private Sub ListBox1_Click() Dim Co As Long Co = ActiveCell.Column If frmJob.ListBox1.ListIndex > 0 Then [PNum] = frmJob.ListBox1.ListIndex [PNam] = frmJob.ListBox1.Text ''MsgBox "Mhhh! Eine gute Wahl!" 'da ja erfolgreich gewählt wurde, 'kann ich die nachfolgenden optionen sichtbar machen.... frmJob.tbQuantperjob.Visible = True frmJob.tbDays.Visible = True frmJob.OptionButton1.Visible = True frmJob.OptionButton2.Visible = True 'menge für ganze kampagne berechnen.... [Quantperday] = main.calcQuantperday(Co, [PNum]) [Daysforchange] = main.calcDaysforchange([PNum], [PreNum]) [quantperjob] = ([Days] - [Daysforchange]) * [Quantperday] frmJob.tbQuantperjob = CInt([quantperjob]) Else 'wenn nur titelzeile gewählt wurde, lieber (wieder) nachfolgende 'optionen unsichtbar machen.... frmJob.tbQuantperjob.Visible = False frmJob.tbDays.Visible = False frmJob.OptionButton1.Visible = False frmJob.OptionButton2.Visible = False End If End Sub Private Sub OptionButton1_Click() 'Days ''tbDays.Value = "" ''tbQuantperjob.Value = "" tbQuantperjob.Enabled = False 'die andere textbox sperren tbDays.Enabled = True 'die eigene textbox öffnen End Sub Private Sub OptionButton2_Click() 'Quant ''tbDays.Value = "" ''tbQuantperjob.Value = "" tbDays.Enabled = False 'die andere textbox sperren tbQuantperjob.Enabled = True 'die eigene textbox öffnen End Sub Private Sub tbQuantperjob_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim D, ueber D = Fix((tbQuantperjob.Value / [Quantperday]) + [Daysforchange]) If D > [daysToMonEnd] Then MsgBox "geht nicht - würde über Monatsende hinausgehen!" D = [daysToMonEnd] ' als höchstmögl. ersatzwert anbieten End If If D > [daystonext] Then ueber = D - [daystonext] If MsgBox(CStr(ueber) & " Tage verlängern, ist das okay?", vbOKCancel, "myprog") <> vbOK Then D = [daystonext] End If End If If D < [Daysforchange] Then MsgBox "Geht nicht - Umstellzeit wäre länger als diese Kampagne! " Exit Sub End If [daystoprolong] = D - [daystonext] frmJob.lbDaystoprolong.Caption = [daystoprolong] tbDays.Value = D: [Days] = D tbQuantperjob.Value = CInt((D - [Daysforchange]) * [Quantperday]) [quantperjob] = tbQuantperjob.Value End Sub Private Sub tbDays_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim D, ueber D = Int(tbDays.Value) '' int ist wichtig, wird sonst nicht als zahl zum vergleichen anerkannt If D > [daysToMonEnd] Then MsgBox "geht nicht - würde über Monatsende hinausgehen!" D = [daysToMonEnd] ' als höchstmögl. ersatzwert anbieten End If If D > [daystonext] Then ueber = D - [daystonext] If MsgBox(CStr(ueber) & " Tage verlängern, ist das okay?", vbOKCancel, "myprog") <> vbOK Then D = [daystonext]: Exit Sub End If End If If D < [Daysforchange] Then MsgBox "Geht nicht - Umstellzeit wäre länger als diese Kampagne! " Exit Sub End If [daystoprolong] = D - [daystonext] frmJob.lbDaystoprolong.Caption = [daystoprolong] tbDays.Value = D: [Days] = D tbQuantperjob.Value = CInt((D - [Daysforchange]) * [Quantperday]) [quantperjob] = tbQuantperjob.Value End Sub