为了给公司CMM兄弟们计算方便,想下载个塞规计算表格,到处下载资料也没有发现共享代码的。都是加密的。
于是下载个类似的又做了下,很多不完善的地方。
此算法计算T,Z值时候没有用到差值,利用了靠近近似。
希望有做过类似的大侠们给点意见。
下一步想做个mathcad 驱动proe生成模型的,希望做过类似的大侠给点资料啥的供参考,谢谢!
塞规计算VBA.rar
(15.2 KB, 下载次数: 2)
Sub p()
Dim j As Integer
j = 0
End Sub
Function dia2()
Dim d As Single
Dim i As Single
d = Sheet2.[c2].Value
Select Case True
Case d >= 0 And d < 3
i = 6
Case d >= 3 And d < 6
i = 7
Case d >= 6 And d < 10
i = 8
Case d >= 10 And d < 18
i = 9
Case d >= 18 And d < 30
i = 10
Case d >= 30 And d < 50
i = 11
Case d >= 50 And d < 80
i = 12
Case Else
MsgBox "直径超80,不计算"
End Select
j = i
''''''''''''''''''''''''''''''''''''''''''
Dim it(1 To 7)
Dim itt(1 To 7) '减去公差值的数组
Dim k As Integer
Dim kk As Integer '下标
Dim m As Integer
Dim c As Single
Dim t As Single
Dim z As Single
m = 2
For k = 1 To 7
it(k) = Sheet1.Cells(j, k + m).Value
itt(k) = Abs(it(k) - 1000 * Sheet2.[g2].Value)
m = m + 2
Next k
c = Application.Min(itt)
kk = Application.Match(c, itt, 0)
t = Sheet1.Cells(i, 3 * kk + 1)
z = Sheet1.Cells(i, 3 * kk + 2)
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheet2.Cells(4, 3) = Round(t, 3)
Sheet2.Cells(5, 3) = Round(z, 3)
End Function
Private Sub CommandButton1_Click()
dia2
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub UserForm_Click()
End Sub
|