Hide Password in Input Box (1 Viewer)

KitaYama

Well-known member
Local time
Tomorrow, 03:58
Joined
Jan 6, 2022
Messages
1,541
For info, standard input boxes cannot handle languages which use unicode characters sets e.g. Arabic, Japanese, Malayalam without changes to locale and keyboard settings. This is also true for standard message boxes

However, I've just posted a web article which includes a new function UnicodeInputBox which does work with Unicode characters sets including right-to-left languages such as Arabic, & Hebrew


For example
View attachment 106139

The language used for the buttons is automatically updated when the Office language is changed

I've not included the code that Ben Sacherich posted earlier but I may merge both sets of code at a later date
@isladogs In the link you provided, a TranslateXL function have been used. May I ask how this function behaves? Does it read the translation from a table?

As you explained, without changing locale, Unicode character set can not be used in vba. My problem at this point is how to pass the Unicode character to UnicodeInputBox function. I do a DLookup against a translator table to pull out the message and show it to the user.

Thanks.
 

isladogs

MVP / VIP
Local time
Today, 19:58
Joined
Jan 14, 2017
Messages
18,219
I use 2 functions: Translate & TranslateXL
Both work in a similar way & can translate from a Latin character set language to a Unicode character set language such as Arabic, Japanese etc
Each sets up a URL to use Google Translate & grabs the output string then processes it

However, only the TranslateXL function can handle translation from a Unicode character set, so I normally use that
An Excel instance is used as an intermediary to setup the encoded URL needed to run the translation

I bypass the locale issue by entering the text in e.g. English & translating each section in code first
For example

Code:
Private Sub cmdUnicode_Click()

   On Error GoTo Err_Handler

      Dim intID As Integer, strP As String, strT As String, strD As String
    
      strP = TranslateXL("Enter a Record ID between 1 and 27", "En", strLang) 'prompt
      strT = TranslateXL("Select Record ID", "En", strLang) 'title
      strD = TranslateXL("Record Number", "En", strLang) 'default value
  
      'UnicodeInputBox works correctly for non-Latin character set
      'The 9000 & 5000 are x & y positions- omit to centre on the screen

      'get the return value
      intID = UnicodeInputBox(strP, strT, strD, 9000, 5000)
    
      'use to move to specified record
      DoCmd.GoToRecord , , acGoTo, intID

Exit_Handler:
  Exit Sub
        
Err_Handler:
  If Err = 13 Then Exit Sub 'user made no entry or pressed cancel
  MsgBox "Error " & Err.Number & " in cmdUnicodeInputBox_Click procedure: " & Err.Description
  Resume Exit_Handler

End Sub

strLang is the code for the language being translated into e.g. ko, ja etc & is set elsewhere
 

KitaYama

Well-known member
Local time
Tomorrow, 03:58
Joined
Jan 6, 2022
Messages
1,541
I use 2 functions: Translate & TranslateXL
Both work in a similar way & can translate from a Latin character set language to a Unicode character set language such as Arabic, Japanese etc
Each sets up a URL to use Google Translate & grabs the output string then processes it

However, only the TranslateXL function can handle translation from a Unicode character set, so I normally use that
An Excel instance is used as an intermediary to setup the encoded URL needed to run the translation

I bypass the locale issue by entering the text in e.g. English & translating each section in code first
For example

Code:
Private Sub cmdUnicode_Click()

   On Error GoTo Err_Handler

      Dim intID As Integer, strP As String, strT As String, strD As String
   
      strP = TranslateXL("Enter a Record ID between 1 and 27", "En", strLang) 'prompt
      strT = TranslateXL("Select Record ID", "En", strLang) 'title
      strD = TranslateXL("Record Number", "En", strLang) 'default value
 
      'UnicodeInputBox works correctly for non-Latin character set
      'The 9000 & 5000 are x & y positions- omit to centre on the screen

      'get the return value
      intID = UnicodeInputBox(strP, strT, strD, 9000, 5000)
   
      'use to move to specified record
      DoCmd.GoToRecord , , acGoTo, intID

Exit_Handler:
  Exit Sub
       
Err_Handler:
  If Err = 13 Then Exit Sub 'user made no entry or pressed cancel
  MsgBox "Error " & Err.Number & " in cmdUnicodeInputBox_Click procedure: " & Err.Description
  Resume Exit_Handler

End Sub

strLang is the code for the language being translated into e.g. ko, ja etc & is set elsewhere
Million thanks for the details. Unfortunately I can not use your method. Most of our PCs in manufacturing line, are set not to connect to internet (by IT) to prevent data breach and Leakage of corporate information.
I think I will stick to pre-translated table method.

I really appreciate your time.
Thank you.
 

isladogs

MVP / VIP
Local time
Today, 19:58
Joined
Jan 14, 2017
Messages
18,219
That makes sense ... if you can't access the internet, you obviously can't use online translation
But how do you get the saved translated strings for all the languages you need?
Do you have native speakers for each language?
 

KitaYama

Well-known member
Local time
Tomorrow, 03:58
Joined
Jan 6, 2022
Messages
1,541
That makes sense ... if you can't access the internet, you obviously can't use online translation
But how do you get the saved translated strings for all the languages you need?
Do you have native speakers for each language?
We have native speakers. But in some cases they can not understand our language. So mostly google translate is used.
The developer uses google translate and saves the result in the table.
 

isladogs

MVP / VIP
Local time
Today, 19:58
Joined
Jan 14, 2017
Messages
18,219
That’s exactly what I do with all caption and control tip text which is translated and stored in a table. The app loops through each object and control in turn so the process is automated. The saved translations are retrieved from the table when the form/report is opened. Similarly for language names used in combo boxes.

At the moment, text used in message boxes, input boxes and the status bar is being translated on the fly and that works fine. I am considering whether to store that info in a table instead but that may not be done in the initial release version
 

KitaYama

Well-known member
Local time
Tomorrow, 03:58
Joined
Jan 6, 2022
Messages
1,541
That’s exactly what I do with all caption and control tip text which is translated and stored in a table.
We stopped using a table for translating forms several years ago. Not that it makes much difference, but we found it's much more simple to add the translation of the controls to its tag. Not only this makes working on forms on design step easier, but also we don't need to go back and forth between the table and the form to add/edit controls' translation. It's much easier to simply edit their tag.

In runtime, there's also no need to open a recordset. Just loop through the controls.
for each control, caption=split(ctrl.tag,"|")(tempvar("lang"))

This will do the job.

I know you're using the tag property for other staffs.

We use Table level translation only for messages.
 

isladogs

MVP / VIP
Local time
Today, 19:58
Joined
Jan 14, 2017
Messages
18,219
Yes, I do use the tag property for many things & had also thought about using the tag property for this purpose.
I'm not sure that retrieving the info from the tag property necessarily makes things easier

1. I'm also translating control tip text so the combined length of caption & control tip text could exceed 255 characters which is (I think) the limit for the tag property.

2. Presumably, you can also only save the data for one language at a time whereas using the table allows me to store/retrieve translations for multiple languages. For example:

1675257680881.png
 

KitaYama

Well-known member
Local time
Tomorrow, 03:58
Joined
Jan 6, 2022
Messages
1,541
Presumably, you can also only save the data for one language at a time
Sorry, I didn't understand this. Do you mean using tag property only one language is possible?
 

isladogs

MVP / VIP
Local time
Today, 19:58
Joined
Jan 14, 2017
Messages
18,219
No. I know its possible to use more than one language in the tag property but if I have (say) 6 different versions of both the caption and control tip for a single control, the string will be very long. Apparently, the limit is 2048 characters
Also, how would you determine to identify which is the correct item to use from the tag?
 

isladogs

MVP / VIP
Local time
Today, 19:58
Joined
Jan 14, 2017
Messages
18,219
Even so, if you have multiple languages for those captions in your tags, it seems to me to be a more complex solution than saving in a table.
if it works for your purposes that's great.
 

Users who are viewing this thread

Top Bottom