Your DimPrec comparison is wrong. Here is a cleaned up version.
However, it's not recommended to be adding a bunch of dim style overrides. It would be better to create a dim style with the precision you want and then use the dim's StyleName property to set the style.
Code:
Public Sub dimTest()
MyDimAligned 1, 1, 0, 0, 0, 0, 0
End Sub
Public Sub MyDimAligned(DimX1 As Double, DimY1 As Double, DimX2 As Double, _
DimY2 As Double, DimLX As Double, DimLY As Double, _
TRot As Double, Optional DimText As String, _
Optional Lsf As Double, Optional DimPrec As Integer)
' If you don't specify the data type, Variant is assumed.
' Use the Optional keyword when applicable. They must be at the end.
' Don't name variables the same as other library names,
' e.g. DimAligned and DimStyle are AutoCAD library names.
Dim Pnt1(0 To 2) As Double
Dim Pnt2(0 To 2) As Double
Dim TextLoc(0 To 2) As Double
Dim dimObj As AcadDimAligned
Dim oDimStyle As AcadDimStyle
Dim DimStyleLSF As Double
Pnt1(0) = DimX1
Pnt1(1) = DimY1
Pnt1(2) = 0
Pnt2(0) = DimX2
Pnt2(1) = DimY2
Pnt2(2) = 0
TextLoc(0) = DimLX
TextLoc(1) = DimLY
TextLoc(2) = 0
Set oDimStyle = ThisDrawing.DimStyles("standard")
ThisDrawing.ActiveDimStyle = oDimStyle
DimStyleLSF = ThisDrawing.GetVariable("DIMLFAC")
Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(Pnt1, Pnt2, TextLoc)
With dimObj
If DimText <> "" Then .TextOverride = DimText
.TextRotation = TRot
If Lsf <> DimStyleLSF And Lsf <> 0 Then .LinearScaleFactor = Lsf
.VerticalTextPosition = acAbove
If DimPrec <> acDimPrecisionSix Then .PrimaryUnitsPrecision = acDimPrecisionSix
.Update
End With
ThisDrawing.Regen acAllViewports
End Sub