By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,482 Members | 1,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,482 IT Pros & Developers. It's quick & easy.

string operations

P: n/a
Sam
Hi,
i'm not very familiar with string operations in vb.net.

How can I simply do the following:

string1 : MM/dd/yyyy
string2 : yyyy MM dd

I want MM to be after dd in each of those string:

string1 would be converted into dd/MM/yyyy
string2 would be converted into yyyy dd MM

The difficulty here is that the separator can be anything
really...(,;.-/$@ etc etc....)

Thx

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Sam" <sa**************@voila.fr> wrote in news:1118667441.694159.182650
@g49g2000cwa.googlegroups.com:
Hi,
i'm not very familiar with string operations in vb.net.

How can I simply do the following:

string1 : MM/dd/yyyy
string2 : yyyy MM dd


Take a look at the Format and formatdate function.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2

P: n/a
Sam
yeah i've checked that already, and i still don't get it......
How can I use IsDate regardless the regional settings. If you know a
way to bypass this, let me know !

my code so far:

Dim MyDate As New DateTime(2005, 12, 31)
CheckDateFormat(row, MyDate, myString)

Public Function CheckDateFormat(ByVal row As DataRow, ByVal aDate As
DateTime, ByRef MyString As String) As Boolean

MyString = aDate.ToString(row("Formatting").ToString)
Return IsDate(MyString)
End Function

Nov 21 '05 #3

P: n/a
Hi:

try to use regional settings date patterns...
Dim strShortDateFormat As String =
System.Globalization.CultureInfo.CurrentCulture.Da teTimeFormat.ShortDatePattern
Dim strLongDateFormat As String =
System.Globalization.CultureInfo.CurrentCulture.Da teTimeFormat.LongDatePattern

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
yeah i've checked that already, and i still don't get it......
How can I use IsDate regardless the regional settings. If you know a
way to bypass this, let me know !

my code so far:

Dim MyDate As New DateTime(2005, 12, 31)
CheckDateFormat(row, MyDate, myString)

Public Function CheckDateFormat(ByVal row As DataRow, ByVal aDate As
DateTime, ByRef MyString As String) As Boolean

MyString = aDate.ToString(row("Formatting").ToString)
Return IsDate(MyString)
End Function

Nov 21 '05 #4

P: n/a
Sam
Actually this would work and returns true as soon as the format is
valid with a culture, whatever it is

For Each ci As CultureInfo In
CultureInfo.GetCultures(CultureTypes.InstalledWin3 2Cultures)
Thread.CurrentThread.CurrentCulture = New
CultureInfo(ci.Name)
ok = IsDate(MyString)
Next

What annoys me is that my boss just told me not to care about that
anymore as we are going to have pre-defined date formats in a combobox
instead........ how to waste your time .....
Thx anyway

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.