Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dates and Internationalization (Regional Settings) in VBA

Status
Not open for further replies.

nuandaEB

Technical User
Oct 22, 2002
8
CA
I have the following problem:
I wrote a program for Word in VBA which creates a schedule
that display addresses in a date range.
The date range is provided through user input.

I know what the Regional Settings will be on the client
computer (they are not set to US English). My code works fine (as long as the date is entered in a format appropriate to the regional settings). However, the date ends up being formatted in the language and format specified in the regional settings.

For example,
Thursday April 10, 2003
appears as
jeudi avril 10, 2003

Is there any way that I can force the Format function in VBA to display the date in English?

I know I can't change the regional settings programmatically (and wouldn't want to), and I don't want to start parsing the full date and translating it programmatically, especially since the regional settings of the client
are set to a non-latin language.

Any help would be greatly appreciated.
Thanks,
EB

 
Yes I think that you could use an array

You should first get the month/day number i.e.
mth=Month(Date)
MyDay= Weekday(Date)

drop the above values into to arrays
Function FindMd(Mth)
Dim Arr
Arr = Array("January", "February", "March", "Etc", "Etc")FindMD = Arr(Mth)
End Function
And a similar for the weekday

Should do the trick
Rgds
Herman
 
Just as a general point from what I've read the best way to manipulate things is to let VBA format things in it's native format (invariably American) then when it crosses the boundary in the Excel interface, if the cells have been pre-formatted to a regional preference, that should automatically be taken account of. Perhaps you wouldn't even have to pre-format, maybe windows regional settings would take care of it for you.

Sorry I couldn't be of more use, it's just something I read recently that may be helpful.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top