有些人喜歡寫 VB 一定要宣告變數,
我則偏好不宣告 (這是 VB 的特色)
最近常用
ArrayVariant()()()... 的方式傳遞, 設定陣列, 有空寫一篇論 Variant 來發表好了...
舉個例子:
Public Function ReSetDemand(ByVal nIndex As Long)
' 依規線重設需求
For i = 1 To DemandCount
For j = 1 To StageCount
WaterDemand(i)(1)(j) = WaterDemand(i)(1)(j) * WaterDemand(i)(2)(nIndex + 1)
Next
Next
End Function
Public Function ReSetRuleCurve(ByVal hRuleCurve As Variant, ByVal CurveIndex As Long)
' 重設規線
For j = 1 To StageCount
RuleCurve(CurveIndex)(1)(j) = hRuleCurve(j)
Next
End Function
其實每個變數都是陣列... 看不出來吧...
hRuleCurve(j) 是 hRuleCurve(j)(1 To 36) 的陣列喔!
忽然覺得, 各種語言的陣列還是 VB 最簡便又不失靈活!