Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub clearFormulare(ByVal newControl As Controls, ByVal rowFormulare As Integer, ByVal columnPerRow As Integer, ByVal nameOfInput As String, ByVal inputDigit As Integer, ByVal inputRange As String)
- For i = 1 To (rowFormulare * columnPerRow) + 1
- newControl(nameOfInput & i).Value = ""
- Next i
- Tabelle2.Cells(inputDigit, inputRange).Value = 0
- Tabelle2.Cells(inputDigit, inputRange).Interior.ColorIndex = 0
- End Sub
- Public Sub returnValues(ByVal newControl As Controls, ByVal saveColumn As Integer, ByVal nameOfInput As String, ByVal uniqNumber As Integer)
- Dim countOfTextboxes As Integer
- Dim endPoint As Integer
- For i = 1 To (uniqNumber) - 1
- endPoint = endPoint + GetSetting("SaveData", "startFrom", i)
- Next i
- 'dont override the last value of the calculate before from class one
- endPoint = endPoint + 1
- For countOfTextboxes = 1 To GetSetting("SaveData", "EndPoint", 2)
- newControl(nameOfInput & countOfTextboxes).Value = Tabelle6.Cells(saveColumn, endPoint).Value
- endPoint = endPoint + 1
- Next countOfTextboxes
- End Sub
- Public Sub buttonBerechnung(ByVal newControl As Controls, ByVal nameOfInput As String, ByVal saveColumn As Integer, ByVal inputRange As String, ByVal inputDigit As Integer, ByVal rowFormulare As Integer, ByVal columnPerRow As Integer, ByVal uniqNumber As Integer)
- Dim countOfTextboxes As Integer
- Dim allInformations() As Double
- Dim valueTax As Double
- Dim decimalPlaces As Integer
- Dim eigcounter As Integer
- Dim resultOfCalculate As Double
- Dim queueOfClass As Integer
- 'Define var
- valueTax = 1.19
- decimalPlaces = 2
- eigcounter = 1
- queueOfClass = 2
- ReDim allInformations(rowFormulare, columnPerRow)
- For i = 1 To rowFormulare
- For j = 1 To columnPerRow
- If (newControl(nameOfInput & eigcounter) = "") Then
- allInformations(i, j) = 0
- Else
- allInformations(i, j) = newControl(nameOfInput & eigcounter)
- End If
- eigcounter = eigcounter + 1
- Next j
- Next i
- 'Calculate brutto netto of input
- '1 = amount z.B Quadratmeter
- '2 = single price netto
- '3 = total netto
- '4 = single price brutto
- '5 = total brutto
- For i = 1 To rowFormulare
- For j = 2 To columnPerRow
- If (allInformations(i, j) > 0) Then
- Select Case j
- 'If input is single price and amount
- Case 2
- allInformations(i, 3) = allInformations(i, 1) * allInformations(i, 2)
- newControl(nameOfInput & 3 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 3), decimalPlaces)
- allInformations(i, 4) = allInformations(i, 2) * valueTax
- newControl(nameOfInput & 4 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 4), decimalPlaces)
- allInformations(i, 5) = allInformations(i, 4) * allInformations(i, 1)
- newControl(nameOfInput & 5 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 5), decimalPlaces)
- 'If input is total netto and amount
- Case 3
- allInformations(i, 2) = (allInformations(i, 2) / valueTax)
- newControl(nameOfInput & 2 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 2), decimalPlaces)
- allInformations(i, 3) = allInformations(i, 2) * allInformations(i, 1)
- newControl(nameOfInput & 3 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 3), decimalPlaces)
- allInformations(i, 5) = allInformations(i, 4) * allInformations(i, 1)
- newControl(nameOfInput & 5 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 5), decimalPlaces)
- 'If input is single brutto and amount
- Case 4
- allInformations(i, 2) = allInformations(i, 3) / allInformations(i, 1)
- newControl(nameOfInput & 2 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 2), decimalPlaces)
- allInformations(i, 4) = allInformations(i, 2) * valueTax
- newControl(nameOfInput & 4 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 4), decimalPlaces)
- allInformations(i, 5) = allInformations(i, 4) * allInformations(i, 1)
- newControl(nameOfInput & 5 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 5), decimalPlaces)
- 'If input is total brutto and amount
- Case 5
- allInformations(i, 4) = allInformations(i, 5) / allInformations(i, 1)
- newControl(nameOfInput & 4 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 4), decimalPlaces)
- allInformations(i, 2) = (allInformations(i, 4) / valueTax)
- newControl(nameOfInput & 2 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 2), decimalPlaces)
- allInformations(i, 3) = allInformations(i, 2) * allInformations(i, 1)
- newControl(nameOfInput & 3 + (columnPerRow * (i - 1))).Value = Round(allInformations(i, 3), decimalPlaces)
- Case Else
- End Select
- 'Otherwise all cases will be true and the program calculate all cases
- j = columnPerRow
- End If
- Next j
- Next i
- 'result
- For indexOfResult = 1 To rowFormulare
- resultOfCalculate = resultOfCalculate + allInformations(indexOfResult, 5)
- Next indexOfResult
- newControl(nameOfInput & ((rowFormulare * columnPerRow) + 1)).Value = resultOfCalculate
- 'painting the cell of the destination > 0
- With Tabelle2
- If (resultOfCalculate <> 0) Then
- .Cells(inputDigit, inputRange).Value = resultOfCalculate
- 'Tabelle2.Cells(inputDigit, inputRange).NumberFormat = "#,##0.00 $"
- .Cells(inputDigit, inputRange).Interior.ColorIndex = 15
- Else
- .Cells(inputDigit, inputRange).Value = 0
- .Cells(inputDigit, inputRange).Interior.ColorIndex = 0
- End If
- End With
- 'save the data
- 'Find out how much textboxes are in the controlfield
- 'For Each c In Me.Controls
- ' If TypeName(c) = "TextBox" Then
- ' countOfTextboxes = countOfTextboxes + 1
- ' End If
- 'Next
- 'save information to table 6
- 'Every Formulare get a unique id which help to find out the correct position of class in save table
- Dim z As Integer
- SaveSetting "SaveData", "startFrom", uniqNumber, GetSetting("SaveData", "EndPoint", queueOfClass)
- 'Its nessesary to fill the textboxes with values
- Dim muchTextboxes
- muchTextboxes = ((rowFormulare * columnPerRow) + 1)
- SaveSetting "SaveData", "EndPoint", uniqNumber, muchTextboxes
- For b = 1 To (uniqNumber - 1)
- z = z + GetSetting("SaveData", "startFrom", b)
- Next b
- 'To get a gape between the classes
- z = z + 1
- For k = 1 To rowFormulare
- For h = 1 To columnPerRow
- Tabelle6.Cells(saveColumn, z).Value = allInformations(k, h)
- z = z + 1
- Next h
- Next k
- 'For the resultBox
- Tabelle6.Cells(saveColumn, z).Value = resultOfCalculate
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement