Advertisement
Guest User

Untitled

a guest
Jan 5th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 11.41 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Public wpText As String 'Klartext für Wartungen
  4.  
  5. Public tbform As String 'Stunden TextBox Formatierung
  6. Public stdform As String 'Stunden Kürzel Formatierung
  7. Public tbstart As String 'Starttext für Stunden TextBox
  8. Public tbdeci As Integer 'Teiler für Stunden Nachkommastelle
  9.  
  10. Public spmin As Integer 'SpinButton min Wert
  11. Public spmax As Integer 'SpinButton max Wert
  12. Public spchange As Integer 'SpinButton change Wert
  13. Public spdelay As Integer 'SpinButton delay Wert
  14.  
  15. Public tbcolor As String 'Farbe für inaktive TextBox
  16.  
  17. Public mname1 As String 'Mitarbeiter Name 1
  18. Public mname2 As String 'Mitarbeiter Name 2
  19. Public mname3 As String 'Mitarbeiter Name 3
  20. Public mname4 As String 'Mitarbeiter Name 4
  21. Public mname5 As String 'Mitarbeiter Name 5
  22.  
  23. ' --------------------------------------------------------------- Bericht erstellen --------------------------------------------------------------------
  24. Private Sub CommandButton1_Click()
  25.  
  26.     If MsgBox("Möchten Sie diesen Bericht wirklich erstellen?", vbYesNo) = vbYes Then
  27.  
  28.     Dim n As Long
  29.    
  30.     ' ///// Art des Berichts exportieren ////////////////////////////////
  31.        Worksheets("Vorlage").Cells(6, 1).Value = ComboBox1.Value
  32.     ' __________________________________________________________________
  33.    
  34.     ' ///// Kunden Daten exportieren ////////////////////////////////////
  35.        Worksheets("Vorlage").Cells(9, 5).Value = UserForm1.Controls("TextBox" & 1).Value
  36.         Worksheets("Vorlage").Cells(10, 5).Value = UserForm1.Controls("TextBox" & 2).Value
  37.         Worksheets("Vorlage").Cells(11, 5).Value = UserForm1.Controls("TextBox" & 3).Value
  38.         Worksheets("Vorlage").Cells(13, 5).Value = UserForm1.Controls("TextBox" & 4).Value
  39.     ' __________________________________________________________________
  40.    
  41.     ' ///// Mitarbeiter exportieren /////////////////////////////////////
  42.        For n = 2 To 6
  43.             Worksheets("Vorlage").Cells(n + 7, 14).Value = UserForm1.Controls("ComboBox" & n).Value
  44.         Next n
  45.     ' __________________________________________________________________
  46.    
  47.    
  48.     ' ///// Datum exportieren ///////////////////////////////////////////
  49.        Dim stdDrive As String
  50.         Dim stdWork As String
  51.         For n = 1 To 5
  52.             stdDrive = UserForm1.Controls("TextBox" & (n + 4)).Value
  53.             stdWork = UserForm1.Controls("TextBox" & (n + 9)).Value
  54.             If stdDrive = "0,00" And stdWork = "0,00" Then
  55.                 Worksheets("Vorlage").Cells(n + 17, 1).Value = ""
  56.                 Else: Worksheets("Vorlage").Cells(n + 17, 1).Value = UserForm1.Controls("DTPicker" & n).Value
  57.             End If
  58.         Next n
  59.     ' __________________________________________________________________
  60.    
  61.    
  62.     ' ///// Übernachtung exportieren ////////////////////////////////////
  63.        For n = 1 To 5
  64.             If UserForm1.Controls("CheckBox" & n).Value = True Then
  65.                     Worksheets("Vorlage").Cells(n + 17, 10) = "X"
  66.                 Else: Worksheets("Vorlage").Cells(n + 17, 10) = ""
  67.             End If
  68.         Next n
  69.     ' __________________________________________________________________
  70.    
  71.     ' ///// Fahr- / Arbeitszeit exportieren /////////////////////////////
  72.        Dim gesSum As String
  73.         gesSum = 0
  74.    
  75.         For n = 5 To 9
  76.             Dim ges As String
  77.             Dim tBox As String
  78.        
  79.             tBox = UserForm1.Controls("TextBox" & n).Value
  80.             If tBox <> "0,00" Then
  81.                     Worksheets("Vorlage").Cells(n + 13, 13).Value = tBox + stdform
  82.                 Else: Worksheets("Vorlage").Cells(n + 13, 13).Value = ""
  83.             End If
  84.        
  85.             tBox = UserForm1.Controls("TextBox" & n + 5).Value
  86.             If tBox <> "0,00" Then
  87.                     Worksheets("Vorlage").Cells(n + 13, 15).Value = tBox + stdform
  88.                 Else: Worksheets("Vorlage").Cells(n + 13, 15).Value = ""
  89.             End If
  90.        
  91.             ges = CDbl(UserForm1.Controls("TextBox" & n)) + CDbl(UserForm1.Controls("TextBox" & n + 5))
  92.             If ges <> 0 Then
  93.                     Worksheets("Vorlage").Cells(n + 13, 17).Value = Format(ges, tbform) & stdform
  94.                 Else: Worksheets("Vorlage").Cells(n + 13, 17).Value = ""
  95.             End If
  96.            
  97.             gesSum = CDbl(gesSum) + CDbl(ges) ' Gesamt Zeit errechnen
  98.            
  99.         Next n
  100.     ' __________________________________________________________________
  101.    
  102.     ' ///// Mitarbeiter Zählen //////////////////////////////////////////
  103.        Dim maCount As Integer
  104.         Dim stdGes As String
  105.         maCount = 0
  106.        
  107.         For n = 9 To 13
  108.             If Worksheets("Vorlage").Cells(n, 14).Value <> "" Then
  109.                 maCount = maCount + 1
  110.             End If
  111.         Next n
  112.         stdGes = CDbl(gesSum) * CDbl(maCount)
  113.     ' __________________________________________________________________
  114.    
  115.     ' ///// Gesamt Zeit exportieren /////////////////////////////////////
  116.        If ComboBox1.ListIndex <> 0 Then
  117.                 Worksheets("Vorlage").Cells(24, 17).Value = Format(gesSum, tbform) & stdform
  118.                 Worksheets("Vorlage").Cells(25, 17).Value = Format(stdGes, tbform) & stdform
  119.             Else
  120.                 Worksheets("Vorlage").Cells(24, 17).Value = wpText
  121.                 Worksheets("Vorlage").Cells(25, 17).Value = wpText
  122.         End If
  123.     ' __________________________________________________________________
  124.    
  125.     ' ///// Ausgeführte Arbeiten exportieren ////////////////////////////
  126.        Worksheets("Vorlage").Cells(29, 1).Value = TextBox15.Value
  127.     ' __________________________________________________________________
  128.    
  129.     ' ///// Unterschriftsfelder exportieren /////////////////////////////
  130.        Worksheets("Vorlage").Cells(64, 1).Value = ComboBox2.Value
  131.         Worksheets("Vorlage").Cells(64, 14).Value = TextBox4.Value
  132.         Worksheets("Vorlage").Cells(65, 1).Value = Date
  133.         Worksheets("Vorlage").Cells(65, 14).Value = Date
  134.     ' __________________________________________________________________
  135.    
  136.     End If
  137.    
  138. End Sub
  139.  
  140. Private Sub SpinButton1_Change()
  141.  
  142.     TextBox5.Text = (SpinButton1.Value / tbdeci)
  143.     TextBox5.Value = Format(TextBox5, tbform)
  144.    
  145.     If TextBox5.Text = tbstart Then
  146.         TextBox5.ForeColor = tbcolor
  147.     Else
  148.         TextBox5.ForeColor = 0
  149.     End If
  150. End Sub
  151. Private Sub SpinButton2_Change()
  152.  
  153.     TextBox6.Text = (SpinButton2.Value / tbdeci)
  154.     TextBox6.Value = Format(TextBox6, tbform)
  155.  
  156.     If TextBox6.Text = tbstart Then
  157.         TextBox6.ForeColor = tbcolor
  158.     Else
  159.         TextBox6.ForeColor = 0
  160.     End If
  161. End Sub
  162. Private Sub SpinButton3_Change()
  163.  
  164.     TextBox7.Text = (SpinButton3.Value / tbdeci)
  165.     TextBox7.Value = Format(TextBox7, tbform)
  166.  
  167.     If TextBox7.Text = tbstart Then
  168.         TextBox7.ForeColor = tbcolor
  169.     Else
  170.         TextBox7.ForeColor = 0
  171.     End If
  172. End Sub
  173. Private Sub SpinButton4_Change()
  174.  
  175.     TextBox8.Text = (SpinButton4.Value / tbdeci)
  176.     TextBox8.Value = Format(TextBox8, tbform)
  177.  
  178.     If TextBox8.Text = tbstart Then
  179.         TextBox8.ForeColor = tbcolor
  180.     Else
  181.         TextBox8.ForeColor = 0
  182.     End If
  183. End Sub
  184. Private Sub SpinButton5_Change()
  185.  
  186.     TextBox9.Text = (SpinButton5.Value / tbdeci)
  187.     TextBox9.Value = Format(TextBox9, tbform)
  188.  
  189.     If TextBox9.Text = tbstart Then
  190.         TextBox9.ForeColor = tbcolor
  191.     Else
  192.         TextBox9.ForeColor = 0
  193.     End If
  194. End Sub
  195. Private Sub SpinButton6_Change()
  196.  
  197.     TextBox10.Text = (SpinButton6.Value / tbdeci)
  198.     TextBox10.Value = Format(TextBox10, tbform)
  199.  
  200.     If TextBox10.Text = tbstart Then
  201.         TextBox10.ForeColor = tbcolor
  202.     Else
  203.         TextBox10.ForeColor = 0
  204.     End If
  205. End Sub
  206. Private Sub SpinButton7_Change()
  207.  
  208.     TextBox11.Text = (SpinButton7.Value / tbdeci)
  209.     TextBox11.Value = Format(TextBox11, tbform)
  210.  
  211.     If TextBox11.Text = tbstart Then
  212.         TextBox11.ForeColor = tbcolor
  213.     Else
  214.         TextBox11.ForeColor = 0
  215.     End If
  216. End Sub
  217. Private Sub SpinButton8_Change()
  218.  
  219.     TextBox12.Text = (SpinButton8.Value / tbdeci)
  220.     TextBox12.Value = Format(TextBox12, tbform)
  221.  
  222.     If TextBox12.Text = tbstart Then
  223.         TextBox12.ForeColor = tbcolor
  224.     Else
  225.         TextBox12.ForeColor = 0
  226.     End If
  227. End Sub
  228. Private Sub SpinButton9_Change()
  229.  
  230.     TextBox13.Text = (SpinButton9.Value / tbdeci)
  231.     TextBox13.Value = Format(TextBox13, tbform)
  232.  
  233.     If TextBox13.Text = tbstart Then
  234.         TextBox13.ForeColor = tbcolor
  235.     Else
  236.         TextBox13.ForeColor = 0
  237.     End If
  238. End Sub
  239. Private Sub SpinButton10_Change()
  240.  
  241.     TextBox14.Text = (SpinButton10.Value / tbdeci)
  242.     TextBox14.Value = Format(TextBox14, tbform)
  243.  
  244.     If TextBox14.Text = tbstart Then
  245.         TextBox14.ForeColor = tbcolor
  246.     Else
  247.         TextBox14.ForeColor = 0
  248.     End If
  249. End Sub
  250.  
  251. Private Sub UserForm_Initialize()
  252.  
  253.     ' --------------------------------------------------------------- Variabeln deklarieren --------------------------------------------------------------------
  254.    wpText = "Wartungspauschale" 'Klartext für Wartungen"
  255.    
  256.     stdform = " std" 'Stunden Kürzel Formatierung
  257.    tbform = "#0.00" 'Stunden TextBox Formatierung
  258.    tbdeci = 2 'Teiler für Stunden Nachkommastelle
  259.    tbstart = "0,00" 'Starttext für Stunden TextBox
  260.    spmin = 0 'SpinButton min Wert
  261.    spmax = 32 'SpinButton max Wert
  262.    spchange = 1 'SpinButton change Wert
  263.    spdelay = 80 'SpinButton delay Wert
  264.    tbcolor = RGB(210, 210, 210) 'Farbe für inaktive TextBox
  265.    
  266.     mname1 = "Ralf Pries" 'Mitarbeiter Name 1
  267.    mname2 = "Henning Meckel" 'Mitarbeiter Name 2
  268.    mname3 = "Florian Skotz" 'Mitarbeiter Name 3
  269.    'mname4 = "HIER NAME EINFÜGEN" 'Mitarbeiter Name 4
  270.    'mname5 = "HIER NAME EINFÜGEN" 'Mitarbeiter Name 5
  271.    
  272.     Dim n As Long
  273.     For n = 5 To 14
  274.     UserForm1.Controls("TextBox" & n).Text = tbstart
  275.     UserForm1.Controls("TextBox" & n).Locked = True
  276.     UserForm1.Controls("TextBox" & n).ForeColor = tbcolor
  277.     Next n
  278.    
  279.     For n = 1 To 10
  280.     UserForm1.Controls("SpinButton" & n).Min = spmin
  281.     UserForm1.Controls("SpinButton" & n).Max = spmax
  282.     UserForm1.Controls("SpinButton" & n).SmallChange = spchange
  283.     UserForm1.Controls("SpinButton" & n).Delay = spdelay
  284.     Next n
  285.    
  286.    
  287.     ' --------------------------------------------------------------- Art des Berichts füllen --------------------------------------------------------------------
  288.    With UserForm1.ComboBox1
  289.         .AddItem "W A R T U N G S B E R I C H T"
  290.         .AddItem "S E R V I C E B E R I C H T"
  291.         .AddItem "R E P E R A T U R B E R I C H T"
  292.         .ListIndex = 1
  293.     End With
  294.    
  295.     ' --------------------------------------------------------------- Kunden Daten Laden --------------------------------------------------------------------
  296.    For n = 1 To 4
  297.         UserForm1.Controls("TextBox" & n).Value = Worksheets("kdDaten").Cells(n + 1, 2).Value
  298.     Next n
  299.    
  300.     ' --------------------------------------------------------------- Namensfelder füllen --------------------------------------------------------------------
  301.    For n = 2 To 6
  302.         With UserForm1.Controls("ComboBox" & n)
  303.             .AddItem ""
  304.             If mname1 <> "" Then .AddItem mname1
  305.             If mname2 <> "" Then .AddItem mname2
  306.             If mname3 <> "" Then .AddItem mname3
  307.             If mname4 <> "" Then .AddItem mname4
  308.             If mname5 <> "" Then .AddItem mname5
  309.         End With
  310.     Next n
  311.    
  312.  
  313. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement