Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Evaluate() revisited
Message
From
01/04/1998 15:04:59
 
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00088744
Message ID:
00088769
Views:
28
>Isn't there a way to do this with Resource files and a little Duct tape? :) Actually, can't you return an error number, use that to extract the proper message from the resource file and if you need to show a value (like a limit, maximum, etc), just concatenate it.
>If not, could you elaborate a little more because I just understand that you want to use the sentence as an index on an array.

The needs:

1. Store 200 messages in an array
2. Most of those messages contains variables values which will only be accessible at run time

When the ActiveX control is initialized, we load all messages into an array. The array will then be used later when we have an error message. Because the array is initialized at first, at that time, the properties does not have any values, so we store everything in one string.

Assuming a specific message is "You need to enter a value not greather than "+Str(lnMaximum), at run time, this expression will be evaluated so it will give "You need to enter a value not greather than 233.", assuming lnMaximum=233.

We could also have an expression like "You need to enter a value between "+Str(lnMinimum)+" and "+Str(lnMaximum)+"." which will result in "You need to enter a value between 0 and 233.", assuming lnMinimum is 0 and lnMaximum is 233.

There is more complexe messages.

The resource file won't help. At one time or another, you'll have to evaluate a string which should be evaluated to its value.

So, again, something like this should work pretty easily:

MsgBox(Evaluate(laMessage(1))

where

laMessage(1) is the entire string from the array row #1 which is

'"You need to enter a value not greather than "+Str(lnMaximum)'

If you're unfamiliar with an Evaluate() function, you may take a look at the Visual FoxPro help. Another terminology of it is sometimes a macro substitution.

Presently, in VB, I have to write about 400 lines instead of 6 because this function does not exist. So, we have a lot of If, If and If, etc. It's not the best but it work. However, when you show this code to a manager, he says, get rid of this dummy technique and use something better.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform