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
Solved

Design Question delaing with Enums and/or structures

Posted on 2003-12-10
6
160 Views
Last Modified: 2010-05-03
I have been assigned the following task in Visual Basic and have not yet decided on the design...
I have a program for which i need to maintain a running history / log of whats going on...
There will be a number of screens and each screen will have a number of actions associated with it. So if someone performs an action, I want it to be logged and called easily in the following format
ScreenName.ActionPerformed

0
Comment
Question by:jainpriyanka
  • 3
6 Comments
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9913351
You would be better off doing it in this format:

LogAction(screenname,ActionPerformed)

then you can just write one function to do what you want.



But if you must have it in the format you want....

1. Create a class called clsAuditLog
2. In the class create a public function for each action that can be performed.
3. In each Screen, put this in the code declaration:
     Dim ScreenName as clsAuditLog

4. Then you will be able to call ScreenName.ActionPerformed


But you will run into problems if you do it this way!!
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9913367
PS. there is no point using enums for the second method I described. In the first method you can use Enums.
0
 

Author Comment

by:jainpriyanka
ID: 9913614
The underlying point of using enums is that i want to restrict the 'Action' variable
i.e. The Patient Select Screen should have only the following actions returned ADD, DELETE and EDIT
the actions change per screen...
0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 50 total points
ID: 9913722
If you use this format for your LogAction function:


LogAction(screenname,ActionPerformed)




Then the code in your module will look like this:

Enum eActionsPerformed
  apAdd
  apDelete
  apEdit
End Enum


Public Function LogAction(ByVal spScreenName as String, Byval ipActionPerformed As eActionsPerformed) As Boolean
  ' Do your stuff
End Function


But keep in mind that making the parameter type an enum does not restrict the values passed to the function, it just provides a helpful popup list! You can still pass any Integer (or Long, can't remember) value

You will still need code like this in your function:



Select Case ipActionPerformed
  Case apAdd
    ' Add Processing
  Case apDelete

  Case apEdit

  Case Else
     ' Raise an error as an invalid type has been passed in
End Select
0
 
LVL 27

Expert Comment

by:planocz
ID: 10260690
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
No response from jainpriyanka from 12/10/2003 comment
Award points to nmcdermaid is recommend.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

planocz
EE Cleanup Volunteer
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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