MsgBox in two languages - How to choose?

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
919
Office Version
  1. 365
Platform
  1. Windows
I made a form that has a radio button pair "Suomeksi" - "In English". Now, I want my message boxes to appear in that chosen language.

How do I do that?

This is what I have done so far:

Code:
Option Explicit

Public strLng As String

Private Sub optEnglish_Click()
    VaihdaKieli ("Eng")
End Sub

Private Sub optFinnish_Click()
    VaihdaKieli ("Fin")
End Sub

Sub VaihdaKieli(strLng As String)
    If strLng = "Eng" Then
        lblINI.Caption = "INI file:"
        lblSource.Caption = "Source file:"
        btnGet.Caption = "Get tags"
    ElseIf strLng = "Fin" Then
        lblINI.Caption = "INI tiedosto:"
        lblSource.Caption = "Lähdetiedosto:"
        btnGet.Caption = "Hae tagit"
    End If
End Sub
Which works fine - It does change the language of the form.

But how do I display message boxes? I tried to use

Code:
    If Not FileOrDirExists(sFName) Then
        If strLng = "Eng" Then
            MsgBox Title:="Error!", Buttons:=vbOKOnly + vbCritical, Prompt:="INI-file can't be found!"
        Else
            MsgBox Title:="Virhe!", Buttons:=vbOKOnly + vbCritical, Prompt:="INI-tiedostoa ei löydy!"
        End If
        Exit Sub
    Else
'...the main code goes here
    End If
Should be pretty easy for anyone who has programmed a multi language program. The problem is probably with variable scope or so.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
One way is to have all your messages be drawn from a translation sheet. For instance:

Excel Workbook
ABC
1EnglishJapaneseFrench
2Cat?Chat
3Dog?Chien
4Ant?Fourmi
5Grasshopper??Cigale
Sheet1


Add a Global Variable called 'Language' or something that equals the column of the target language.

Then instead of writing MsgBox("Dog") you can write:
MsgBox(Worksheets("Sheet1").Range("A3").Offset(0,Language))

That will offset "Dog" (A3) by as many columns as the selected language.

Then you just set your radio button to control language (0-2).
 
Upvote 0
One way is to have all your messages be drawn from a translation sheet. For instance:

Excel Workbook
ABC
1EnglishJapaneseFrench
2Cat?Chat
3Dog?Chien
4Ant?Fourmi
5Grasshopper??Cigale
Sheet1


Add a Global Variable called 'Language' or something that equals the column of the target language.

Then instead of writing MsgBox("Dog") you can write:
MsgBox(Worksheets("Sheet1").Range("A3").Offset(0,Language))

That will offset "Dog" (A3) by as many columns as the selected language.

Then you just set your radio button to control language (0-2).

Ok, I think I can make it with this. Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,520
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top