You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.1 KiB
QBasic

Attribute VB_Name = "modValues"
Option Explicit
Public Function CreateValue(Element As Control, Flag As Boolean, addValue As Double, MinMaxExistsFlag As Boolean, Optional Min As Double, Optional Max As Double) As Boolean
If MinMaxExistsFlag = True Then
If Element.Value >= Element.MaxValue Then
Flag = False
ElseIf Element.Value <= Element.MinValue Then
Flag = True
End If
If Flag = True Then
Element.Value = Element.Value + addValue
Else
Element.Value = Element.Value - addValue
End If
Else
If Element.Value >= Max Then
Flag = False
ElseIf Element.Value <= Min Then
Flag = True
End If
If Flag = True Then
Element.Value = Element.Value + addValue
Else
Element.Value = Element.Value - addValue
End If
End If
CreateValue = Flag
End Function
Public Function CreateState(Element As Control, Flag As Boolean, addValue As Double, MinMaxExistsFlag As Boolean, Optional Min As Double, Optional Max As Double) As Boolean
If MinMaxExistsFlag = True Then
If Element.State >= Element.MaxState Then
Flag = False
ElseIf Element.State <= Element.MinState Then
Flag = True
End If
If Flag = True Then
Element.State = Element.State + addValue
Else
Element.State = Element.State - addValue
End If
Else
If Element.State >= Max Then
Flag = False
ElseIf Element.State <= Min Then
Flag = True
End If
If Flag = True Then
Element.State = Element.State + addValue
Else
Element.State = Element.State - addValue
End If
End If
CreateState = Flag
End Function
Public Function CreateRandomValue(Optional Max As Double) As Double
CreateRandomValue = Max * Rnd
End Function