Что я мог понять из деталей
Нет необходимости в цикле для ручного управления, и layerNumber
может быть просто получено из значений TextBox
(или непосредственно из ячеек) с формулой
LayerNumber = ((Elevation - MinElevation) / ElevationStep) * NumberOfRotations + (Rotation - MinRotation) / RotationStep
Кнопки «Вращение» и «Высота» Плюс и Минус (или счетчики) можно использовать для увеличения или уменьшения значения «Вращение и высота» с шагами, определенными как Макс., Мин.
Наконец, программное обеспечение VR можно вызвать с любого нажатия кнопки с помощью LayerID
Я попробовал вот так, чтобы сгенерировать LayerID
по уже сделанным кнопкам и т. Д.
Названия кнопок, имена листов и т. Д. Могут быть изменены в соответствии с вашими потребностями. если мои предположения не верны, не стесняйтесь, чтобы описать ваши потребности.
Option Explicit
Private Sub ElvMinus_Click()
Dim ElevationStep, MinElevation, MaxElevation, Elevation As Integer
ElevationStep = Val(Sheet2.ElevationStepBox.Text)
MinElevation = Val(Sheet2.MinElevationAngleBox.Text)
MaxElevation = Val(Sheet2.MaxElevationAngleBox.Text)
Elevation = Val(Sheet2.AngleOfElevationBox.Text)
Elevation = Elevation - ElevationStep
Elevation = IIf(Elevation < MinElevation, MinElevation, Elevation)
Sheet2.AngleOfElevationBox.Text = Elevation
GetLayerID
End Sub
Private Sub ElvPlus_Click()
Dim ElevationStep, MinElevation, MaxElevation, Elevation As Integer
ElevationStep = Val(Sheet2.ElevationStepBox.Text)
MinElevation = Val(Sheet2.MinElevationAngleBox.Text)
MaxElevation = Val(Sheet2.MaxElevationAngleBox.Text)
Elevation = Val(Sheet2.AngleOfElevationBox.Text)
Elevation = Elevation + ElevationStep
Elevation = IIf(Elevation > MaxElevation, MaxElevation, Elevation)
Sheet2.AngleOfElevationBox.Text = Elevation
GetLayerID
End Sub
Private Sub RotMinus_Click()
Dim RotationStep, MinRotation, MaxRotation, Rotation As Integer
RotationStep = Val(Sheet2.RotationStepBox.Text)
MinRotation = Val(Sheet2.MinRotationAngleBox.Text)
MaxRotation = Val(Sheet2.MaxRotationAngleBox.Text)
Rotation = Val(Sheet2.AngleOfRotationBox.Text)
Rotation = Rotation - RotationStep
Rotation = IIf(Rotation < MinRotation, MinRotation, Rotation)
Sheet2.AngleOfRotationBox.Text = Rotation
GetLayerID
End Sub
Private Sub RotPlus_Click()
Dim RotationStep, MinRotation, MaxRotation, Rotation As Integer
RotationStep = Val(Sheet2.RotationStepBox.Text)
MinRotation = Val(Sheet2.MinRotationAngleBox.Text)
MaxRotation = Val(Sheet2.MaxRotationAngleBox.Text)
Rotation = Val(Sheet2.AngleOfRotationBox.Text)
Rotation = Rotation + RotationStep
Rotation = IIf(Rotation > MaxRotation, MaxRotation, Rotation)
Sheet2.AngleOfRotationBox.Text = Rotation
GetLayerID
End Sub
Private Sub GetLayerID()
Dim RotationStep, ElevationStep, MinRotation, MaxRotation, ElevatioStep, MinElevation, MaxElevation As Integer
Dim NumberOfRotations, NumberOfElevations, NumberOfSunPositions As Integer
Dim Elevation, Rotation, layerNumber As Integer
RotationStep = Val(Sheet2.RotationStepBox.Text)
MinRotation = Val(Sheet2.MinRotationAngleBox.Text)
MaxRotation = Val(Sheet2.MaxRotationAngleBox.Text)
ElevationStep = Val(Sheet2.ElevationStepBox.Text)
MinElevation = Val(Sheet2.MinElevationAngleBox.Text)
MaxElevation = Val(Sheet2.MaxElevationAngleBox.Text)
NumberOfRotations = (MaxRotation - MinRotation) / RotationStep + 1
NumberOfElevations = (MaxElevation - MinElevation) / ElevationStep + 1
NumberOfSunPositions = NumberOfRotations * NumberOfElevations
Sheet2.NumberOfSunPositionsBox.Text = NumberOfSunPositions
Elevation = Val(Sheet2.AngleOfElevationBox.Text)
Rotation = Val(Sheet2.AngleOfRotationBox.Text)
layerNumber = ((Elevation - MinElevation) / ElevationStep) * NumberOfRotations + (Rotation - MinRotation) / RotationStep
Sheet2.layerNumber.Text = layerNumber
' Here call to VR Software
End Sub