Learn how to a build a cloud-first strategyRegister Now

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

can i use validating when changing the value of a variable?

this may seem like a stupid question to u experts but I'm wondering if its possible to use the 'validating' method when changing the value of a variable....?

let me explain...i have form that i manipluate to perform many different operations such as add, delete, search for records etc...i have a variable that holds the mode that the form is currently in such again as adding, deleting etc.

What i am asking is if when say leaving adding mode to go to another mode such as searching...is it possible to use the validating method to check whether a save is needed etc.

hope this isnt too dull a question to ask...
  • 3
  • 2
1 Solution
Well Not Dull of course.....
But may I suggest using a property instead of a variable.
You won't require the Validating event then here's a small eg how...

 Private CurrentMode As String

    Public Property Mode() As String
            Mode = CurrentMode
        End Get
        Set(ByVal Value As String)
            'We are about to go to Some Other Mode
            'Do whatever Checking you want Here
            CurrentMode = Value
        End Set
    End Property

And your code would be using Mode property (NOT CURRENTMODE variable)

for eg.
say from your Serach() method you'd set

(And not CurrentMode="Serach")

scm0smlAuthor Commented:
mmmmmmm i havent used anything like that b4...bit of a novice u c!!

ill hav to hav a look into it.
That's the standard way with variables, you see.
It is always recommended to use a property to wrap up the variable, and to use the property instead of using the variable directly. It gives you a sort of abstraction and the flexibility to do some manipulations whenever its values are changed.

scm0smlAuthor Commented:
yeah sounds good...will lokk into it.

thanks again!!

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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