Function XuanJin(MinD As Integer, MaxD As Integer, Area As Long) As String
MsgBox "你给的钢筋 面积是" & Area
MsgBox "选筋的最小直径" & MinD
MsgBox "选筋的最大直径" & MaxD
Dim MinDArea As Long
MinDArea= MinD ^ 2 * 3.14 / 4 ' 最小直径钢筋单根面积
Dim n As Integer
n = Fix(Area / MinDArea) '需要最小直径钢筋的根数
Dim i As Integer
Dim j As Integer
Dim m As Integer
Dim L As Integer
Dim tempArea As Long
Dim WuCha As Integer
Dim MinWuCha As Integer
MinWuCha = 100
'优先选用小直径钢筋
If n < 2 Then
XuanJin = "2D" & MinD '两根最小直径钢筋已经满足
Else
'4层循环嵌套(两种钢筋直径和各自的根数循环)
For i = MinD To MaxD
If isInArray(i) = True Then
For j = 1 To n
For m = MinD To MaxD
For L = 1 To n
If isInArray(m) = True Then
tempArea = j * i ^ 2 * 3.14 / 4 + L * m ^ 2 * 3.14 / 4 '所选钢筋面积
WuCha = Abs(tempArea - Area) / Area * 100 '钢筋面积误差
If MinWuCha > WuCha Then '误差小于最小误差
MinWuCha = WuCha '最小误差则等于该误差
'记录误差偏小时所选用的钢筋
If i = m Then '所选的钢筋同直径
XuanJin = (j + L) & "D" & i
Else '所选钢筋有两种直径
XuanJin = j & "D" & i & "+" & L & "D" & m
End If
End If
End If
Next L
Next m
Next j
End If
Next i
End If
End Function
Sub xuanjian()
Dim Jin As String
Jin = XuanJin(16, 25, 180)
MsgBox Jin
End Sub
'判断是否是有效的钢筋直径
Function isInArray(d As Integer) As Boolean
isInArray = False
Dim Ds As Variant
Ds = Array(4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 30, 32, 36, 40)
Dim i As Integer
For i = 0 To 15
If Ds(i) = d Then isInArray = True
Next
End Function
MsgBox "你给的钢筋 面积是" & Area
MsgBox "选筋的最小直径" & MinD
MsgBox "选筋的最大直径" & MaxD
Dim MinDArea As Long
MinDArea= MinD ^ 2 * 3.14 / 4 ' 最小直径钢筋单根面积
Dim n As Integer
n = Fix(Area / MinDArea) '需要最小直径钢筋的根数
Dim i As Integer
Dim j As Integer
Dim m As Integer
Dim L As Integer
Dim tempArea As Long
Dim WuCha As Integer
Dim MinWuCha As Integer
MinWuCha = 100
'优先选用小直径钢筋
If n < 2 Then
XuanJin = "2D" & MinD '两根最小直径钢筋已经满足
Else
'4层循环嵌套(两种钢筋直径和各自的根数循环)
For i = MinD To MaxD
If isInArray(i) = True Then
For j = 1 To n
For m = MinD To MaxD
For L = 1 To n
If isInArray(m) = True Then
tempArea = j * i ^ 2 * 3.14 / 4 + L * m ^ 2 * 3.14 / 4 '所选钢筋面积
WuCha = Abs(tempArea - Area) / Area * 100 '钢筋面积误差
If MinWuCha > WuCha Then '误差小于最小误差
MinWuCha = WuCha '最小误差则等于该误差
'记录误差偏小时所选用的钢筋
If i = m Then '所选的钢筋同直径
XuanJin = (j + L) & "D" & i
Else '所选钢筋有两种直径
XuanJin = j & "D" & i & "+" & L & "D" & m
End If
End If
End If
Next L
Next m
Next j
End If
Next i
End If
End Function
Sub xuanjian()
Dim Jin As String
Jin = XuanJin(16, 25, 180)
MsgBox Jin
End Sub
'判断是否是有效的钢筋直径
Function isInArray(d As Integer) As Boolean
isInArray = False
Dim Ds As Variant
Ds = Array(4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 30, 32, 36, 40)
Dim i As Integer
For i = 0 To 15
If Ds(i) = d Then isInArray = True
Next
End Function
'板选筋
Function xuanjin2(MinD As Integer, MaxD As Integer, MinJianJu As Integer, MaxJianJu As Integer, Area As Long) As String
Dim MinDArea As Long
MinDArea = MinD ^ 2 * 3.14 / 4 ' 最小直径钢筋单根面积
Dim MaxDArea As Long
MaxDArea = MaxD ^ 2 * 3.14 / 4 ' 最大直径钢筋单根面积
If MaxDArea * 1000 / MinJianJu < Area Then '最大直径钢筋和最小钢筋间距都不能满足要求
xuanjin2 = 0
End If
Dim N As Double
Dim i As Integer
Dim j As Integer
Dim tempArea As Long
Dim WuCha As Integer
Dim MinWuCha As Integer
MinWuCha = 100
For i = MinD To MaxD
If isInArray(i) = True Then
For j = MinJianJu To MaxJianJu Step 10
N = 1000 / j
tempArea = N * i ^ 2 * 3.14 / 4 '所选钢筋面积
WuCha = Abs(tempArea - Area) / Area * 100 '钢筋面积误差
If MinWuCha > WuCha Then '误差小于最小误差
MinWuCha = WuCha '最小误差则等于该误差
'记录误差偏小时所选用的钢筋
xuanjin2 = i & "@" & j
End If
Next j
End If
Next i
End Function
Dim MinDArea As Long
MinDArea = MinD ^ 2 * 3.14 / 4 ' 最小直径钢筋单根面积
Dim MaxDArea As Long
MaxDArea = MaxD ^ 2 * 3.14 / 4 ' 最大直径钢筋单根面积
If MaxDArea * 1000 / MinJianJu < Area Then '最大直径钢筋和最小钢筋间距都不能满足要求
xuanjin2 = 0
End If
Dim N As Double
Dim i As Integer
Dim j As Integer
Dim tempArea As Long
Dim WuCha As Integer
Dim MinWuCha As Integer
MinWuCha = 100
For i = MinD To MaxD
If isInArray(i) = True Then
For j = MinJianJu To MaxJianJu Step 10
N = 1000 / j
tempArea = N * i ^ 2 * 3.14 / 4 '所选钢筋面积
WuCha = Abs(tempArea - Area) / Area * 100 '钢筋面积误差
If MinWuCha > WuCha Then '误差小于最小误差
MinWuCha = WuCha '最小误差则等于该误差
'记录误差偏小时所选用的钢筋
xuanjin2 = i & "@" & j
End If
Next j
End If
Next i
End Function
[本日志由 tiancao1001 于 2008-09-23 02:33 PM 编辑]
|
田草 于 2008-07-31 09:52 PM 发表评论:
发表评论 - 不要忘了输入验证码哦! |