Windows Language Settings
Hello,
I have a problem with Language Settings. In my software I am using English (United States) as the default language. But people using other languages except this facing problem. Sometimes they get errors, sometimes they do not get the desired results, sometimes they do not get any results either. To solve the problem what am I need to do ? Please advice. Can I get any help from API ? Then let me know the API functions.
Here I designed my logic in either of the following two ways.
1. Let the user enter date, month, year as per his choice of language. My software can change it in English language and return the output in english.
2. My software can accept the language, convert it in english, return the result in user language.
Please provide guidelines. I need this as soon as possible.
Thank you so much in advance.
Re: Windows Language Settings
It sounds to me as if your problems are related to the use of dates, is this correct?
If so, I assume that you are either not using the Date data type, or are not using it properly (when used properly, the language/regional settings do not matter).
If you can explain (preferably with code samples) what you are doing with dates, we can help you correct the issues.
1 Attachment(s)
Re: Windows Language Settings
Thank you for the reply sir.
I am sending you the source code in zip format. In English language settings (what I set from Control Panel) it will run perfectly and gives you the reslt. But if you change the language to any other except English then it will provides you error assking for a frmMain.log and will not provide you result.
Please help me out of here.
Thank you so much for the reply and in advance for the upcoming help.
Re: Windows Language Settings
First of all, you need to read this: What is wrong with using "On Error Resume Next"? (and probably other "how to deal with errors" articles in our ClassicVB FAQs).
Ok... there are at least two major problems with your code, and to my surprise one of them does actually get shown because of language settings - I think it is the first time I've ever been able to say that!
This happens because you add the months to the list like this:
Code:
cboMonthF.AddItem MonthName(i)
..and then check the selection like this:
Code:
If strBirthMonth = "January" Then
If you want to have certain text ("January") in the combo then specifically add that text, don't rely on VB's built-in functions, as they do often use regional equivalents (so wont match what you have written).
If you want to use the regional version of the text (eg: "Janvier" (sp?) for French) in the combo, then add it to the list as you do now - but compare the text to the regional equivalent too, eg:
If strBirthMonth = MonthName(1) Then
There is also a better alternative than either of these - but we'll come to that after the next problem.
The second problem is simply due to bad use of data types, and here is a perfect example:
Code:
If strBirthDate >= 20 Then
Here you are comparing a String to a Number, which means that the results are not reliable... this is because VB needs to convert one of them to the same data type as the other - and they are likely to actually be compared as Strings.
When you compare Strings, the first characters of each string are compared, and if one has a lower ASCII code then that string is "less than" the other (if identical, the 2nd character of each string is compared). To prove that, run this code:
Code:
If "2" > "123124" Then
MsgBox "Hello!"
End If
If you want to treat a String as a number, convert it to one before you do so, eg:
Code:
If CInt(strBirthDate) >= 20 Then
strSunSign = "Aquarius"
Else 'no need for an "ElseIf", as we already know it is not 20 or more
strSunSign = "Capricorn"
End If
However, there is no need for you to be using a string in the first place - instead of reading the .Text from the combo, read the .ListIndex (selected item position) instead, eg:
Code:
Dim intMonthM as Integer
intMonthM = cboMonthM.ListIndex + 1 'we need the "+ 1", as the positions start at 0.
..then simply alter the SunSign routine to take an Integer as the parameter, and do the comparisons using numbers, eg: If intBirthDate >= 20 Then
If you do the same for months, this will solve the other problem too.
Re: Windows Language Settings
Thank you vey much sir / madam. Your notes and suggestions are really helpful to me. Please provide me more on the basic of programming languages, if possible. Can I talk to you online ? Please reply.
Once again thank you so much.
Re: Windows Language Settings
To learn more about VB, see the Classic VB FAQs link in my signature, it contains lots of useful articles.