我在 Visual Basic 2010 的设计视图中有一个很大的对象列表,我需要为其更改一堆属性,所以我当然尝试使用数组而不是使用 50-60 行来完成重复性任务。但似乎有一个引用该对象的问题,它似乎只是从中获取信息。我知道这是一个糟糕的解释,但也许你看到它就会明白。
Dim objectsToClear As Array = _
{lblDailyRoundTrip, lblDaysWorked, lblFillBoxes, lblMilesPerGallon, lblMonthlyInsurance, _
lblMonthlyMaintenance, lblMonthlyParking, tbDailyRoundTrip, tbDaysWorked, tbMilesPerGallon, _
tbMonthlyInsurance, tbMonthlyMaintenance, tbMonthlyParking}
For i = LBound(objectsToClear) To UBound(objectsToClear)
objectsToClear(i).Text = ""
objectsToClear(i).Visible = False
Next