How would you make a variable have a limit of zero being the lowest you can go? (In runtime the user will be subracting from a variable, and I don't want it to go below 0).
I do not know of an integer variable with a minimum of zero, but if there is and you try to set it to a below zero value you wil get an error.
Creating a property wil do it, reading the property will look like this:
Text1 = Form1.myposint
setting the property wil look like this:
Form1.myposint = Text1
the property looks like this:
Dim aPositiveInt As Integer
Public Property Let myposint(new_myposint As Integer)
If new_myposint > -1 Then
aPositiveInt = new_myposint
Else
' Something is trying to give a value lower than 0 take appropriate action
MsgBox "Can`t make the value lower than zero"
End If
End Property
Public Property Get myposint() As Integer
myposint = aPositiveInt
End Property
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.