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.

Code:
stringVal = "200402"
In VB6 code
Code:
Format$(stringVal, "@@@@/@@/@@")
after conversion wizard in
VB.Net it is written
Code:
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
 

IanRyder

Well-known member
Joined
Sep 9, 2012
Messages
1,130
Location
Healing, NE Lincs, UK
Programming Experience
10+
Hi,

Give this example a try:-

Code:
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
 
Top Bottom