Military time converting

I am trying to make a program in VB that will convert military time to standard time. I have a simple GUI that has a place to input military time then another text box to show the standard time, then a button to press to do the conversion. I have no idea how to do the code, can anyone help?

Thank you,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It is very easy..  You just use the Format function.  
Do you mean the 24 hour clock?

You only need to change the Format to display in your chosen style.

This will show in 24 hour format.

TextBox2.Text = Format(CDate(TextBox1.Text), "hh:mm")

This will show in 12 hour format

TextBox2.Text = Format(CDate(TextBox1.Text, "hh:mm AM/PM"))
This should give you an idea:

        MsgBox(Format("HHmmssa", CDate("23:45:22")))
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Of course replace the "23:25:22", with the string from your textbox...

txtStdTime.text=Format("HHmmssa", CDate(txtMilTime.Text))
VinnyG3Author Commented:
I tried the code below and im getting an error. Am i doing something wrong?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox2.Text = Format("HHmmssa", CDate(TextBox1.Text))
    End Sub

Open in new window

Most of us probably assumed you were using tradidtional VB as opposed to .Net.

What is the error?
VinnyG3Author Commented:
InvalidCastException was unhandled
Conversion from string "22.35.03" to type 'Date' is not valid.

Yes i am using VB express 2005
try using 22:35:03 instead

if you must use periods then write a routine to replace all periods with ":" because that is what Format expects.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VinnyG3Author Commented:
Thank you very much
You are welcome.  I'd also suggest validating user input to allow only numbers 0-9 and two ":" in the proper places before trying to convert it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.