Solved

Design Question delaing with Enums and/or structures

Posted on 2003-12-10
6
158 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now