Link to home
Start Free TrialLog in
Avatar of M3hcSS
M3hcSS

asked on

Given a variable length string (11:15 OR 9:30), how do I use Substring to pull out the first number?

This works if the hour is 11:15
myTime.Substring(0,2)

This works if the hour is 9:30
myTime.Substring(0,1)

How do I make it so it works with either string? I don't know ahead of time how long the string is.
ASKER CERTIFIED SOLUTION
Avatar of neilprice
neilprice

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of M3hcSS
M3hcSS

ASKER

That's actually a really freaky answer.
Avatar of M3hcSS

ASKER

To get the minutes to the right side of the colon...

JUNKTimeOn1.Substring((JUNKTimeOn1.IndexOf(":")+1),2)