string operations

  • Thread starter Thread starter Sam
  • Start date Start date
S

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
 
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.
 
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
 
Hi:

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

Regards,
Josip Habjan
URL: http://www.habjansoftware.com
 
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.InstalledWin32Cultures)
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
 
Back
Top