how do I create a geometric shape as a class? Visual basic has a Rectangle class pre-defined object that I would like to use, but I need to use a rectangle class that can use decimals for the 4 points to set its location. I do not want to draw a shape on the form for graphical reasons but I want to use the shape for an algorithm, how can I create a class for a rectangle using decimals? Thanks and I am a beginner using visual basic so I would appreciate help in as much detail as possible. Thanks again in advance
Share
If you need to use decimal values for the four points of the rectangle, you need to use the
RectangleFstructure, instead of the regularRectanglestructure. It accepts values of typeSingle, and is already built-in to the .NET Framework.The
Fat the end of the name stands for “floating-point”, which refers to the decimal point. Computers store numbers with decimal points a bit differently than they do integers. Rather than being fixed at any specific position, the position of the decimal is allowed to “float”. A pretty complicated concept to explain in an answer to such a simple question, but you can get a detailed explanation here if you’re confused.(By the way, the
RectangleandRectangleFobjects are actually structures, rather than classes.It’s a distinction that probably seems somewhat minor or even irrelevant when you’re first learning the language, but it becomes important later. All you need to know right now is that when you’re defining your own types, you should always use a class rather than a structure.)