String trim problem

itayzoro

Member
Joined
Jul 28, 2008
Messages
23
Programming Experience
Beginner
I got this string : "12{TAB}30/07/2008 11:53:18{TAB}4"

what i need is to turn it into this one : ""12{TAB}20080730115318{TAB}4"
lets say i will find a way to get rid from the "/" and the ":" but how i turn the year month and day?
 
Hello.

You could extract the substring, load the date, write it in the new format and put the string back together.

VB.NET:
dim temp() as String = yourString.Split("{TAB}")
dim result as String = temp(0) & "{TAB}" & Date.ParseExact(temp(1), "dd/MM/yyyy hh:mm:ss").toString("yyyyMMddhhmmss", Nothing) & "{TAB}" & temp(2)

Bobby
 
Yes its right but

the DataBase give me a diffrent Date so i cant use the local Date !!

Dim q As String = "12{TAB}30/07/200811:53:18{TAB}4"
q = q.Replace("/", "")
q = q.Replace(":", "")
q = q.Substring(0, 7) & q.Substring(11, 4) & q.Substring(9, 2) & q.Substring(7, 2) & q.Substring(15)

I can use this but i dont no how to insert vbtab after the "12" string and before the "4"
 
ParseExact is parsing the given string as date, means that it's not using the local time, but it's parsing your date within the string (that's why we gave him the format, so he knows where to look for what).

Treat vbTab as normal string:
VB.NET:
q = q.Substring(0, 7).Replace("{TAB}", vbTab) & q.Substring(11, 4) & q.Substring(9, 2) & q.Substring(7, 2) & q.Substring(15).Replace("{TAB}", vbTab)

Bobby
 
Back
Top