Link to home
Start Free TrialLog in
Avatar of OFGemini
OFGemini

asked on

Change the language of an exceptions message

How can I change the language of an exception's messsage?

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of OFGemini
OFGemini

ASKER

Hi TheLearnedOne,

I tried setting CurrentCulture and CurrentUICulture but I'm still gettting english for my exception's message.  What am I missing here?

Here is the code:

Imports System.Globalization
Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim Spanish As CultureInfo = CultureInfo.CreateSpecificCulture("es-CO")

        System.Threading.Thread.CurrentThread.CurrentCulture = Spanish
        System.Threading.Thread.CurrentThread.CurrentUICulture = Spanish

        Try
            Throw New DivideByZeroException
        Catch ex As Exception

            'I want this message to change language.
            MsgBox(ex.Message)
        End Try


    End Sub
End Class
What operating system?  Do you have multi-language packs installed?

Bob
I use winXP pro.  How can I tell if I have multi-language packs installed?
I am not sure how Windows XP works with languages, but you might be able to check on the regional control panel applet.

Bob