Visual Basic: Saving Custom Control Persistant Properties

For more on this subject Google Search on VB Initproperties

You may wonder why we need the InitProperties event since the UserControl property already has an Initialize event in common with Class modules and other objects, such as forms.

The reason that we need InitProperties to initialize default values is that the Initialize event happens too often, that is, every time an instance or your control "wakes up." You only want the default property values to be assigned when the developers first sites a new copy of your control on a container. After that, you want the developer to be able to define persistent property values.

WARNING – Don't Use the Initialize Event to Set an ActiveX Control's Default Property Values : If you put code to initialize properties to their default values in your custom ActiveX control's Initialize event instead of in the InitProperties event, then you will have some very frustrated developers on your hands. Your default values will override the values the developer has assigned at design time every time the developer runs an application using your control.

The Property Bag is a persistent UserControl object containing the values of your control's custom, extender, and delegated properties. In fact, the Property Bag is so persistent that it doesn't get destroyed with the instances of the UserControl. This means you can store property values in the Property Bag just before an instance of the UserControl is destroyed and then retrieve the stored values when a new instance of the UserControl "wakes up" in another part of the development life cycle.

The Property Bag has two methods to store and retrieve values respectively:

  • The WriteProperty method

  • The ReadProperty method

You must know how to manipulate the Property Bag in the following situations that we discuss in the sections immediately following this one:

  • You store property values into the PropertyBag by calling its WriteProperty method in the WriteProperties event procedure.

  • You retrieve property values from the PropertyBag by calling its ReadProperty method in the ReadProperties event procedure.

  • You ensure that the WriteProperties event will fire by calling the PropertyChanged method. You'll usually do this in the Property Let procedures of your custom properties or at other appropriate places in your code where the storage value of a property changes.

—-

The operating environment fires a UserControl's ReadProperties and WriteProperties events whenever it thinks that the instantiated object's properties need to be re-initialized (ReadProperties event fires) or stored for safekeeping (WriteProperties event fires).

This arrangement makes it much easier for you, the control author, to manage these properties since you don't have to think about all the possible occasions when property values might need reading or writing. You simply need to put code for reading and writing property values in two centralized places: the ReadProperties and WriteProperties event procedures.

…………more

Visual Basic PropertyBags to remember Parameters-Its in the Bag

Recalling UserControl Properties

Standard controls have properties you can set using the object browser.  The next time you bring up your VB program for editing you need to be able to recall the state of these settings.  Example #3 on this page  shows how to use a PropertyBag to remember these settings.

 

             

  BagMan PropertyBag Example

Storage to the Bag

Save to the Bag – Fill up the object to be saved to disk Stuff it in the Bag – The actual file operation to put on disk

 Private Sub cmdSave_Click()

  Dim objBag As New PropertyBag

    With objBag
        .WriteProperty "Str", "A string"
        .WriteProperty "Num", 666
        .WriteProperty "Bool", False
        .WriteProperty "Mascot", SuperBagMan.Picture

        SaveBagContents .Contents, App.Path & "\Things.bag"
    End With
   
    Set objBag = Nothing

End Sub  

                                                                                                               

Private Sub SaveBagContents(Contents As Variant, FilePath As String)

  Dim FileNum As Integer

    FileNum = FileSystem.FreeFile()

    Open FilePath For Binary As FileNum
        Put #FileNum, , Contents
    Close FileNum

End Sub

 

 

……….more

Creative useful ideas for sellers names on ebay

One of the funniest things I ever saw on ebay was the name of the user.   They chose the following name

      AuctionOver

What is so funny about this is that when you first saw it you thought oh damnit….I missed the bidding.  Now this only worked for about 1/2 a second on me but anyone who did not look closely would just keeping clicking and skip bidding. Thus this humorous user would get better prices on that which he bought.

International Citizens Band Radio day October Fourth 10-4

International Citizens Band Radio day October Fourth *( 10-4 ) will soon be upon us.  Do you have your CB radios in working order and ready to transmit ?  Make sure no miscreant has pinned your coax.  Fire up your radio and make sure everything is ready for TEN-FOUR.  

In America Its customary to give gifts on this day.  Have you bought your wife the Bearcat scanner she's had her eye on?

Sandals stink a bit-How do you get teva rubber sandals to stop stinking after you sweat in them? Stopping teva sandals stinking

How do you get teva rubber sandals to stop stinking after you sweat in them.? My Teva sandals smell a little bit. How can I get them to stop kickin?   Use my sandal mummification process.

My solution is easier if you have 2 pairs.  Get an old shoebox and dump a bunch of Borax in it.  Take one pair and and bury them cover them in Borax.  Let them rest their for a while.  This works pretty well in Arizona where its very dry.  The Borax sucks the moisture out and a bit of it diffuses into the sandal material. Borax is antibacterial and you will find your sandals smelling alot better.  You can do this on a nightly basis but what works best is to leave them in the borax a week so you do not have to dust them off everyday.  Simply pull out the ones that have been mummifying for a week and put your second pair in.  Then you always have a stink free pair.

Cube Sequences

13=1

13+23=9  = 32                         

13+23+33=36 = 62

13+23+33+43=100 = 102

13+23+33+43+53=225 = 152

…. 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16….

These are triangular numbers are in bold: 

  • 1+2 =3
  • 1+2+3=6
  • 1+2+3+4=10

          ( n(n+1)/2 )2= n2(n+1)2/4

A question I have in my mind is that Fermat's last theorem states: If an integer n is greater than 2, then the equation an + bn = cn has no solutions in non-zero integers a, b, and c

But how about  a3 + b3 + c3 = d       … Are there any integer solutions to this?   I ask this because geometrically speaking volume is 1 degree of freedom more than area.

      33+43+53=63             …. = 152 – 32

 

A Cottagers Tea Room by George Michaels-If someone comes in for a good honest shit it is like a breath of fresh air

Larry Craig tippy tapping his toe beneath the stall wall.  Barney Frank peering over the partition.  On the other side George Michael of Wham fame.     Appears there was the commodious underground but they all appear to have passion was for members of the armed forces.

On the wall is written:

     beware of limbo dancers

     I am 9 inches long and two inches thick. Interested?

     Fascinated dear, but how big is your dick?

This bathroom is so cruisy that if someone comes in there for a good honest shit it is like a breath of fresh air.

 Do you know Morse code?  Do you use the tippy tap toe telegraph ?   And you wonder why they always are talking about the reach across the aisle?  

As the SWAT team surrounded the lew Larry Craig is quoted as shouting "I'M NOT COMING OUT!"  What would old Thomas Crapper have to say about all this?

On the whole there is no glory in this story.  Outside the roto-router team works day and night to unclog the lines.  Frequent is heard the cry "MAN THE HOLE"

WP Classifieds Plugin Installation errors – Invalid argument supplied for foreach() in /wp-includes/functions.php on line 1052

I tried installing the wp-classifieds plugin.  When I did I received the following error message:

   Invalid argument supplied for foreach() in …..   /wp-includes/functions.php on line 1052

Where the …. continuation is the first part of my URL which will differ from yours.  When I de-installed this plug in my top page wordpress theme was messed up.  It was rendered very narrow and I still had the above error line listed twice before the page rendering.  

In order to get the theme back to normal I went into the DESIGN menu and re-selected my theme.  After that the rendering was back to normal.

I really want to try this plugin but will need the authors assistance before I can do this.  http://forgani.com/wpclassified-plugins/

Drink Red Wine before running to lose weight

I run everyday lately because I wanted to lose some weight and lower my blood pressure.  The easiest way to keep blood pressure down and make the run more easy is to drink 1/3 of a cup of red wine before my jog. Here is the sequence:

  • drink 1/3 cup of wine to thin blood and dialate capillairys about 45 minutes before running
  • Continuously drink water during the subsequent 45 minutes. This also thins blood. 
  • Run 2.5 miles
  • do the run in the mid to late afternoon.  I do not wait till evening or I will have trouble sleeping
  • The wine will help you your muscles be more loose from the beginning. Warm up time shortened.
  • If you want to goose things up a bit you can start your day drinking water then 1/2 cup of coffee – only a little as coffee drys you out pretty badly – green tea is better.

Now you may think this is just another dumb health tip but its not.  There is something in the red wine that makes you lose fat much MUCH more effectively.  I have tried loosing weight running 6 miles without the wine and lose very little and very slowly.  Whereas when I use the wine its much easier.

I am 47 years old and was seeing 130 / 80 blood pressure with resting heart rate of 60 beats per minute before starting running again.  This is not a good set of numbers for me.  After 2 months of wine and training its 120 / 53 with 47 beats per minute.

The last time I did this was when I was 38.  I was combining it with lifting weights and it was highly effective.  The photo below is from 1999 when I was 38.   I do not know what is in red wine that makes it so effective in increasing health and fitness but whatever it is it works for me.   I wish I would have known about this from day 1 of life as I believe it probably extends life just as some scientific reports are finding.  It may be as little as helping people just stay fit. 

Red wine definitely slightly supresses my appetite.