• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

If you assign a value but it is invalid how to send back a flag

In the below code, I would only like to assign values that are greater than 0.

How do I send back a flag to say that is was not assigned to the property.
If I did this would it be a standard practice.

Public Property Let ExchangeRate(value As Double)
    If mExchangeRate <> value Then
        mExchangeRate = value
        mIsDirty = True
    End If
End Property

0
swansonplace
Asked:
swansonplace
3 Solutions
 
Mark_FreeSoftwareCommented:

You could use a messagebox to notify the user
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Are you talking about notifying the end user or the programmer?

If the programmer, then you can use a function instead of a property.  The function would return true/false to indicate if the value was updated or not.
0
 
ExtremeFitnessCommented:
Not sure you can do it with a property, how about a function to do the same??

Public function ExchangeRate(value As Double) as Boolean
    If mExchangeRate <> value Then
        mExchangeRate = value
        mIsDirty = True
        ExchangeRate = True
    End If
End Property

ExchangeRate(100) = True if the number value was changed
False if not...
0
 
Kaleb2000acCommented:
Hi
As this is a property there are 3 solusions
1. You can raise an error when the value is negative using RaiseError function but it will stop the program when that happends
2. You can validate and if it is invalid force it to a predefined value.

Luck
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now