Question Inserting "/" using String.Format method

tats

New member
Joined
Apr 22, 2013
Messages
2
Programming Experience
Beginner
Hi all,

I've been doing a conversion from VB6 to VB.Net and i used the conversion wizard.

VB.NET:
stringVal = "200402"

In VB6 code
VB.NET:
Format$(stringVal, "@@@@/@@/@@")
after conversion wizard in
VB.Net it is written
VB.NET:
VB6.Format(stringVal, "@@@@/@@/@@")
it uses VB6 compatibility dll.

my question is how do i implement it in .Net so i would not used VB6 compatibility dll
the output will be 20/04/02

Thanks
 
Hi,

Give this example a try:-

VB.NET:
Dim stringVal As String = "200402"
Dim myDate As Date = Date.ParseExact(stringVal, "ddMMyy", Globalization.CultureInfo.InvariantCulture)
 
MsgBox(myDate.ToString("dd/MM/yy"))

In this example, we convert your string into a valid date using the ParseExact method of the Date type and then output this in any format that we need.

Hope that helps.

Cheers,

Ian
 
Back
Top