Solved

Integers and Enumerated Types

Posted on 1997-04-19
3
166 Views
Last Modified: 2010-05-18

Does anyone know how to accomplish this?

type
  TMonths = (January, February, March, etc.);

var
  WhichMonth : TMonths;

...

  Form1.Tag := ord(WhichMonth);
 
  {More Code}

  WhichMonth := TMonth(Form1.Tag)  <<== This is the problem

...

How do you get from an integer type to an enumerated type?

0
Comment
Question by:coppola
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
alona041797 earned 50 total points
ID: 1335536
Your code is correct, except it is TMonths and not TMonth:

This:
  WhichMonth := TMonths(Form1.Tag);
should work.

If this is not the problem please type the error you get.
DO NOT REJECT THIS ANSWER!
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335537
Ah, reject it...just out of principle...she/he used CAPS, which is akin to her/he shouting at you!!  Heh heh.

But I might want to answer this..... *sigh*
0
 

Author Comment

by:coppola
ID: 1335538
My problem was not a typo. I'm using TMonths as an example. My code is more involved and I thought that this would be easier to follow using months.

The problem persists. The error I get is at compile time:
Incompatible Types integer and TModules

The actual code generating the error is:

  previousModule := currentModule;
  currentModule := constructModuleFromID(TModules(TMenuItem(Sender).Tag));
  if currentModule <> nil then begin
    currentModule.Start;
    previousModule.Free;
    end;

A little more research has led me to believe that this is an order of evaluation problem. If I declare a TModules variable and perform the type conversion before the function call, it works.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

737 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