Hi, conditional statements where wrong,
QTYValueNew = QTYValueNew + Math.Round(QTYValueNew / 20) is the 5%
QTYValueNew = Math.Round(QTYValueNew * 1000, 2) roundup is based on mm so I convert m to mm
try this one
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oPartslist As PartsList = oSheet.PartsLists.Item(1)
Dim rows As PartsListRows = oPartslist.PartsListRows
Dim row As PartsListRow = Nothing
Dim Columns As PartsListColumns = oPartslist.PartsListColumns
Dim Partslistrows As New List(Of PartsListRow)
For Each row In rows
row.Item("QTY").Static = False
Next
For Each row In rows
Dim QTYValue As String = (row.Item("QTY").Value)
If QTYValue.Contains("in") Then
Dim cleanString As String = Replace(QTYValue, "in", "")
Dim QTYValueNew As Double = CDbl(cleanString)
QTYValueNew = QTYValueNew * 25.4 'convert in to mm
QTYValueNew = Math.Round(QTYValueNew + (QTYValueNew / 20), 2) 'add 5%
row.Item("QTY").Value = CStr(QTYValueNew)
row.Item("QTY").Static = True
ElseIf QTYValue.Contains("mm") Then
Dim cleanString As String = Replace(QTYValue, "mm", "")
Dim QTYValueNew As Double = CDbl(cleanString)
QTYValueNew = Math.Round(QTYValueNew + (QTYValueNew / 20), 2) 'add 5%
row.Item("QTY").Value = CStr(QTYValueNew)
row.Item("QTY").Static = True
ElseIf QTYValue.Contains("m") Then
Dim cleanString As String = Replace(QTYValue, "m", "")
Dim QTYValueNew As Double = CDbl(cleanString)
QTYValueNew = QTYValueNew * 1000 'convert m to mm
QTYValueNew = Math.Round(QTYValueNew + (QTYValueNew / 20), 2) 'add 5%
row.Item("QTY").Value = CStr(QTYValueNew)
row.Item("QTY").Static = True
End If
Next
For Each row In rows
Dim Valuestart As Double = 0
Dim value2 As Double = 5000
Dim QTYValue As String = (row.Item("QTY").Value)
If row.Item("QTY").Static = True Then
Dim count As Integer = 2
For i = 1 To 1000
Dim QTYValueNew As Double = CDbl(QTYValue)
If QTYValueNew < 5000 Then
row.Item("QTY").Value = CStr(1)
row.Item("QTY").Static = True
End If
If QTYValueNew >= value2 AndAlso QTYValueNew < value2 * 2 Then
row.Item("QTY").Value = CStr(count)
row.Item("QTY").Static = True
End If
value2 = value2 + 5000
count = count + 1
If value2 > QTYValue Then
Exit For
End If
Next
End If
Next