473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

show date in two languages

Hi,

i want to show the current date in two languages.
when i use this code it works, but i have to set the application to the
culture and because this will become a function inside a usercontrol, i do
not want to change the culture for the application just to get a different
language text...

Anyone an idea?

Dim c As CultureInfo
c = New CultureInfo("en-US")
Application.CurrentCulture = c
Dim sEnglish As String = Format(Now, c.DateTimeFormat.LongDatePattern())

c = New CultureInfo("fr-CH")
Application.CurrentCulture = c
Dim sFrance As String = Format(Now, c.DateTimeFormat.LongDatePattern())
Nov 21 '05 #1
2 1757


Willie jan wrote:
Hi,

i want to show the current date in two languages.
when i use this code it works, but i have to set the application to the
culture and because this will become a function inside a usercontrol, i do
not want to change the culture for the application just to get a different
language text...

Anyone an idea?

Dim c As CultureInfo
c = New CultureInfo("en-US")
Application.CurrentCulture = c
Dim sEnglish As String = Format(Now, c.DateTimeFormat.LongDatePattern())

c = New CultureInfo("fr-CH")
Application.CurrentCulture = c
Dim sFrance As String = Format(Now, c.DateTimeFormat.LongDatePattern())


You have the right idea, it's just a matter of searching around in the
Framework for the right method. As it happens, the DateTime type (Date
in VB) overrides its ToString method in a number of ways, one of which
provides exactly what you want:

Imports System.Globalization

Dim dt As Date = Now
Dim US As CultureInfo = New CultureInfo("en-US")
Dim FR As CultureInfo = New CultureInfo("fr-FR")

MsgBox(dt.ToString("D", US.DateTimeFormat))
MsgBox(dt.ToString("D", FR.DateTimeFormat))

Here "D" specifies Long Date (the "DateTimeFormatInfo Class" help topic
has the list).

--
Larry Lard
Replies to group please

Nov 21 '05 #2
thanks, this helps me a lot.

Willie Jan.

"Larry Lard" <la*******@hotmail.com> schreef in bericht
news:11**********************@g47g2000cwa.googlegr oups.com...


Willie jan wrote:
Hi,

i want to show the current date in two languages.
when i use this code it works, but i have to set the application to the
culture and because this will become a function inside a usercontrol, i
do
not want to change the culture for the application just to get a
different
language text...

Anyone an idea?

Dim c As CultureInfo
c = New CultureInfo("en-US")
Application.CurrentCulture = c
Dim sEnglish As String = Format(Now, c.DateTimeFormat.LongDatePattern())

c = New CultureInfo("fr-CH")
Application.CurrentCulture = c
Dim sFrance As String = Format(Now, c.DateTimeFormat.LongDatePattern())


You have the right idea, it's just a matter of searching around in the
Framework for the right method. As it happens, the DateTime type (Date
in VB) overrides its ToString method in a number of ways, one of which
provides exactly what you want:

Imports System.Globalization

Dim dt As Date = Now
Dim US As CultureInfo = New CultureInfo("en-US")
Dim FR As CultureInfo = New CultureInfo("fr-FR")

MsgBox(dt.ToString("D", US.DateTimeFormat))
MsgBox(dt.ToString("D", FR.DateTimeFormat))

Here "D" specifies Long Date (the "DateTimeFormatInfo Class" help topic
has the list).

--
Larry Lard
Replies to group please

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jan Nielsen | last post by:
Hi I have a dataform that shows a date from a MSDE 2000 in a textbox. It uses the format: dd-mm-yyyy hh:mm:ss It would it to use the format dd-mm-yyyy But I can't find a Format property for the...
9
by: Fred Morrison | last post by:
I need to bind a true date value to a listbox control via a DataSet that contains true date values (not strings). The problem is, the list contains the time (always midnight in my case). Other...
9
by: Rizwan Karedoa | last post by:
Hi experts, I am developing an application, I am using vb 2005 and access. I have many date fields, When I am saving through Query for default date I save 1/1/1500 so when i find that date agian I...
0
by: shapper | last post by:
Hello, I have created a GridView on runtime by implementing the ITemplate class. This Gridview displays a list of articles. Each article has a Title, Content and PubDate. I am trying to...
2
by: neoupadhyay | last post by:
Hi friends:- I wann to display only date on gird, but it display both date and time together..what i do to display only date..the code i use is... command.Parameters.AddWithValue("@StartDate",...
7
variouz3ckz
by: variouz3ckz | last post by:
Guys, will some send me some hints on how to display a time and date in my form... the basic one because im just starting to learn VB!
2
by: ragazzo | last post by:
I am using this code to load files But i have problem when there is a large number of files, ( it shows nothing ) is it posible to list only files where date modified is today`s date. And show in...
11
by: fran7 | last post by:
Hi, I wonder if anyone can help. I have a query like this <% If datediff("d", , now()) < 21 Then %> <a target=_blank title="blog" href="news</a> <% Else %>
4
by: flyboy3300 | last post by:
I am trying to set up a form in db with items that have to be completed and when completed they check a "check box" and then I would like that to show a date/time in a text box. I have tried to use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.