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

Posted on 2005-04-19
Last Modified: 2010-04-23
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 it possible to use the validating method to check whether a save is needed etc.

hope this isnt too dull a question to ask...
Question by:scm0sml
    LVL 19

    Accepted 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

    LVL 19

    Expert Comment

    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")


    Author Comment

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

    ill hav to hav a look into it.
    LVL 19

    Expert Comment

    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.


    Author Comment

    yeah sounds good...will lokk into it.

    thanks again!!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now