Solved

Design Question delaing with Enums and/or structures

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 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

10 Experts available now in Live!

Get 1:1 Help Now