Glenn or Antonio, some coding advice?

Jul 08, 2005 3 Replies

Glenn, Antonio et al,



You both have shown a lot higher knowledge in regards to the finer points of coding and working behind the scenes at the code level of RMS. Would you be kind enough to possibly provide a little excerpt or suggestion regarding the implementation of Public Properties and RMS?



I have posted a few times in the past days in regards to some code minutae and think that this may benefit people other than myself.



In examining the other accessible elements of RMS, there are a number of defined properties. My understanding of Properties is limited to a few Google searched pages.



formatting link
:



3 steps to Properties
1 A Private variable to hold the property value
2 A Property Let procedure for setting the property value (if the variable will hold an object reference, you will use a Property Set procedure instead)
3 A Property Get procedure for retrieving the property value


-------------------------- Public Property Get WeightScale() As WeightScale



End Property



--------------------------



Since WeightScale is an Object, I assume it should be used with Set.



The Property Get could then be used to poll the Weight As Double Value?



If you can, and I am sorry to impose on anyone, could you please give a little more insight if your schedule allows? I appreciate all of your contributions to the board as they have helped me and others a lot!



Thanks, Kevin


Properties is an attribute of a class... that can have a get/set method.. If you write in C++ you no have property.. but with two function you have the same goal...

Yes.. Weight is a double.. and the motive for which you have a data-type with name 'WeightScale' is only for code-legible (??? what I write??) because it's no difference from WeightScale and double...

antonio

Are you asking about creating your own properties in VB6, or accessing properties from QSRules?

Here's a sample function that shows how to use the WeightScale object. This is just from using the Object Browser to examine the object, I've never tried to access hardware directly, but this is how it SHOULD work. I don't have a scale to test on, so I have no idea if this code will be functional, or if you need to do anything to initialize the scale...

Private Function GetScaleWeight(byref session as object) as double

dim objScale as QSRules.WeightScale dim dblWeight as Double dim eResult as QSRules.StatusCategoryEnum

set objScale = session.Register.WeightScale

if not objScale is nothing then eResult = objScale.Read(dblWeight)

'You'll have to experiment with the values of eResult ' I think zero is a success result, but it's not clearly stated if eResult = 0 then GetScaleWeight = dblWeight else 'Didn't Get a good result 'Raise a message and error here GetScaleWeight = 0 end if else 'Didn't get a scale object 'Raise a message and error here GetScaleWeight=0 end if

Set objScale = Nothing

End Function

Glenn, I haven't been keeping up with the newsgroups, and lo and behold I come across this gem! I'm going to give it a shot, I apologize for not having read this earlier! Moreover, it makes me come across as unappreciative and ungrateful for all of the helpful hints and suggestions that you have been kind enough to put forward in the newsgroup.

Thanks!

Kevin

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required