473,395 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Trap a message box.

PhilOfWalton
1,430 Expert 1GB
I have built a Db that translates other Databases into any language you choose. Still very much at the testing stage, but one German Db with 24 forms and 24 reports as well as my own Db written in English with 9 forms and 3 reports took 64 minutes to translate into English, German, French and Spanish. (A total of 607 words * 4 languages - 2400 odd words)

Translating from both German and English to Greek was slower taking 23 minutes

In addition I translate any message box messages found in the code of forms, reports & modules

Not Every word will translate if it is incorrectly spelled in the original language, and I ended up with the 607 original words + 2080 translated words

Thereafter, form & reports pause for about a second before loading in the correct language.

Anyway, that's background stuff.

My problem now is I can show the translated message box by changing the code from
Expand|Select|Wrap|Line Numbers
  1. Msgbox "My Message", VbInformation, "Message Box Title"
  2.  
to
Expand|Select|Wrap|Line Numbers
  1. DbT_MessageBox "My Message", VbInformation, "Message Box Title"
  2.  
In addition I can predefine the message using
Expand|Select|Wrap|Line Numbers
  1. DbT_Msg = "Are you a happy bunny?"
  2. If DbT_MessageBox(DbT_Msg, vbYesNo + VbQuestion) = vbNo then ...
  3.  
I purposely didn't use DbT_MsgBox because, if there is no solution to the problem, it is a comparatively simple matter to scan the code and change Msgbox to DbT_MessageBox

My question is, and I think it very unlikely, is there a way of "trapping" the standard Msgbox routine so that I can substitute the translated message before it is displayed?

I really want to avoid altering the original Client's Db if possible

Phil
Oct 31 '17 #1

✓ answered by Rabbit

Wouldn't trapping the standard routine require altering the client's database? You would have to insert some sort of module that's constantly running to trap the MsgBox routine.

Irregardless, I want to say it's probably technically possible by tapping into the Window's APIs. But I don't know how that would be done off the top of my head.

I thought you were already modifying the database by translating strings into another language? Shouldn't the strings in the MsgBoxes also been translated as part of the process?

One way to do what you want without changing existing modules and without having to replace all function calls with your Dbt_MsgBox function is to overload the existing MsgBox function.

Expand|Select|Wrap|Line Numbers
  1. Function MsgBox(Prompt, Optional Buttons, Optional Title, Optional HelpFile, Optional Context) As VbMsgBoxResult
  2.     MsgBox = VBA.MsgBox("overwritten", Buttons, Title, HelpFile, Context)
  3. End Function

8 1897
NeoPa
32,556 Expert Mod 16PB
Yes. Define the same procedure as Public in a standard module.
Nov 1 '17 #2
Rabbit
12,516 Expert Mod 8TB
Wouldn't trapping the standard routine require altering the client's database? You would have to insert some sort of module that's constantly running to trap the MsgBox routine.

Irregardless, I want to say it's probably technically possible by tapping into the Window's APIs. But I don't know how that would be done off the top of my head.

I thought you were already modifying the database by translating strings into another language? Shouldn't the strings in the MsgBoxes also been translated as part of the process?

One way to do what you want without changing existing modules and without having to replace all function calls with your Dbt_MsgBox function is to overload the existing MsgBox function.

Expand|Select|Wrap|Line Numbers
  1. Function MsgBox(Prompt, Optional Buttons, Optional Title, Optional HelpFile, Optional Context) As VbMsgBoxResult
  2.     MsgBox = VBA.MsgBox("overwritten", Buttons, Title, HelpFile, Context)
  3. End Function
Nov 1 '17 #3
PhilOfWalton
1,430 Expert 1GB
Thanks Rabbit, Phase 1 works like a charm.

Slight change to the code so it may be useful for others
Expand|Select|Wrap|Line Numbers
  1.  
  2. Function Msgbox(Prompt As String, Optional Buttons, Optional Title, Optional HelpFile, Optional Context) As VbMsgBoxResult
  3.     ' Wrapper for msgbox
  4.  
  5.     Dim TranslatedMsg As String
  6.     Dim LanguageID As Long
  7.  
  8.     LanguageID = TempVars!RequiredLanguageID
  9.  
  10.     TranslatedMsg = TranslateMsgBox(Prompt, LanguageID)
  11.  
  12.     Msgbox = VBA.Msgbox(TranslateMsg, IIf(Not IsMissing(Buttons), Buttons, 0), _
  13.     IIf(Not IsMissing(Title), Title, ""), _
  14.     IIf(Not IsMissing(HelpFile), HelpFile, ""), _
  15.     IIf(Not IsMissing(Context), Context, 0))
  16.  
  17. End Function
  18.  
The Tempvars gives the language to translate to and the TranslatMsgBox gives the translated message.

Again, very gratefut thanks

Phil
Nov 3 '17 #4
PhilOfWalton
1,430 Expert 1GB
Ah! I spoke too soon.

I have a main database and a library database.

The above routine works perfectly in the library database, but, not unexpectedly, if I use Msgbox in the main database, it uses the standard Msgbox function, rather than invoking the new Msgbox functin in the library database.

I doubt whether it's possible to force the main database to use the CodeDb Msgbox.

I hope I'm wrong

Phil
Nov 4 '17 #5
NeoPa
32,556 Expert Mod 16PB
You could change it manually on a database by setting the order of the references such that the library is higher up than the VBA library (which provides the original MsgBox() function) but not sure you could do that to a database using code. I expect there is a way if you search for it.
Nov 4 '17 #6
Rabbit
12,516 Expert Mod 8TB
I'm a little confused, how exactly is the translation database interacting with the main database?
Nov 4 '17 #7
PhilOfWalton
1,430 Expert 1GB
@ Neopa

'Fraid that doesn't work because, as far as I can see the first 2 references are Visual Basic for Applications and Access Object ... Library. They seem immobile so the best I can do is put my Library Database (DbTranslator) at number 3. Certainly can't do it using the up & down buttons in the "Available References" window.

@Rabbit
The idea is to take any Client's database and by adding the above Db as a library database and adding an Autoexec, after translating the Client's db into whatever languages he chooses (can have multiple languages) and he just changes the output language to French, German, Greek etc to see the forms, reports & MsgBox's in the required language.

Initially the translation rate is about 20 words per minute. The Client's Db that I am playing round with at the moment has 24 forms and 24 reports. That together with the DbTranslator consisting of 9 forms & 3 reports takes about 30 minutes per language to translate. Once done, there is a slight delay of perhaps a couple of seconds to load the translated form or report in the required language.

Your routine traps the Msgbox in the DbTranslator database and displays the message in the correct language, but messages in the Client's Db aren't trapped.

Again I appreciate your input

Phil
Nov 5 '17 #8
Rabbit
12,516 Expert Mod 8TB
How are you translating the client's database without modifying it?
Nov 5 '17 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: aj | last post by:
DB2 WSE LUW 8.1 Fixpak 5 Red Hat AS 2.1 Has anyone ever seen a db2diag.log indicate that a trap file was written, but it is *not* written? For the 3rd time in 18 months, I had a production...
2
by: Bob Darlington | last post by:
When a user clears a value from a combo box (by pressing the delete key), the following message appears: "You tried to assign the null value to a variable that is not a variant data type". ...
18
by: Mantorok Redgormor | last post by:
What does a trap representation mean in the standard? And how can ~0 cause a trap representation? Could someone point out the relevant sections in the standard?
10
by: Bennett F. Dill | last post by:
Hi I'd like help writing a c# console app that can send an SNMP trap. I've seen some documents on writng an SNMP server, but I don't want to receive traps, I only want to send them. Thanks Ben
0
by: Jack Wright | last post by:
Dear All, I have a web Application "http://localhost/Web/WebForm1.aspx" that calls a WebService from "http://localhost/webserviceapp/service1.asmx"...I have set the executionTimeout to 10 secs in...
10
by: pemo | last post by:
As far as I understand it, a trap representation means something like - an uninitialised automatic variable might /implicitly/ hold a bit-pattern that, if read, *might* cause a 'trap' (I'm not...
0
by: Bill Schmidt | last post by:
I am attempting to send an SNMP trap using C#. however I have been unable to find a way to do it. websearching has turned up a small number of 3rd party tools that should be able to do this,...
6
by: temper3243 | last post by:
Hi Can someone explain me what is happening below ? Why is it printing 401380 $ cat scanf.c #include<stdio.h> int main() { int i; scanf(" %d",&i);
6
by: John | last post by:
In a form how I can I trap for the action that a user opens the built in 'find dialog'? I would like to trap for it and before the dialog shows up, I would like to execute some code, and after that...
2
by: EManning | last post by:
I posted a question on 5/5/08 asking how to trap an error caused by multiple users trying to access the same patient. Here's what I posted: "Using A2003. I've got an FE with a main form with a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.