• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Design Question delaing with Enums and/or structures

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
jainpriyanka
Asked:
jainpriyanka
  • 3
1 Solution
 
nmcdermaidCommented:
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
 
nmcdermaidCommented:
PS. there is no point using enums for the second method I described. In the first method you can use Enums.
0
 
jainpriyankaAuthor Commented:
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
 
nmcdermaidCommented:
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
 
planoczCommented:
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now