Need to get Time down to the 0.1 seconds in a number string

  • Thread starter Thread starter jack
  • Start date Start date
J

jack

Hello,

I need to get the time down the the 0.1 second in a number string.

Example

09-06-03 13:45 23.4 Seconds

To "0906031345234"

Thanks in advance,

Jack
 
You could use the RegEx class to remove all characters, except digits.
Something like

newString = RegEx.Replace("10-03-06 10:31 23.4 Seconds", "^[0-9]", "")
 
Minor mistake in that, should read:

newString = RegEx.Replace("10-03-06 10:31 23.4 Seconds", "[^0-9]", "")

Remember to Import System.Text.RegularExpressions

Richard Brown said:
You could use the RegEx class to remove all characters, except digits.
Something like

newString = RegEx.Replace("10-03-06 10:31 23.4 Seconds", "^[0-9]", "")

jack said:
Hello,

I need to get the time down the the 0.1 second in a number string.

Example

09-06-03 13:45 23.4 Seconds

To "0906031345234"

Thanks in advance,

Jack
 
Hi Jack,

|| I need to get the time down the the 0.1 second in a number string.

?? I don't understand this.


But looking at your example, there are a number of solutions of which here's one:

If the string is always in <exactly> the same format you can just copy out
the required portions:

T = "09-06-03 13:45 23.4"
sNumbers = Mid (T, 1, 2) & Mid(T, 4, 2) & etc.

Regards,
Fergus

[Sorry about replying directly - I hit the wrong Reply button]
 
[Sorry about replying directly - I hit the wrong Reply button]

Yeah yeah, you're just building your very own client base, adding to that
great Fergusoft empire where world domination is the only goal. Determined
to change the rules of the software world and to drive smaller companies
into liquidation, "tsk" and "tsk" and more "tsk"'ing sounds made in your
general direction!!!

BTW have you seen...

http://microscum.kurttrail.com/

I first came across this site when I first joined this newsgroup stangely
enough, there was a guy REALLY kicking off at anyone representing Microsoft.
I have only just got around to reading the "details" within his web site so
to speak and was quite suprised at the little snippets of information that I
picked up.... like shrink wrap licenses for example, now if you ever needed
a giant "tsk"'ing machine for anything, it should be for that, oh well, alls
fair in world domination! ;-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Hi Nick,

LOL

Fergus J. Cooney Esq, BSc, DIT
Managing Director,
FergusSoft,
A member of the
Fergus Group of Companies.
 
Jack,
In addition to the others comments.

Is you time in a DateTime object?

I would use a custom format:

' Create your date time as:
' year, month, day, hour, minute, second, milliseconds
Dim d As New DateTime(3, 9, 6, 13, 45, 23, 400)

Dim s As String = d.ToString("MMddyyHHmmssf")

Which says 2 digit month, 2 digit day, 2 digit year, 2 digit (24) hour, 2
digit minute, 2 digit second, 1 digit fraction of second.

For details on Date Time formatting see:
http://msdn.microsoft.com/library/d...s/cpguide/html/cpcondatetimeformatstrings.asp

However, why are you using m/d/y in your format string? I would think y/m/d
would be safer, at least y/m/d sorts "better".

Hope this helps
Jay
 
Fergus J. Cooney Esq, BSc, DIT
Managing Director,
FergusSoft,
A member of the
Fergus Group of Companies.

LOL

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Back
Top