time format hh:mm:ss tt yields time like 10:45:30 tt--not am or pm

We have recently upgraded our application from Visual Basic 4 to Visual Basic 6.  A text box shows the time, utilizing the format set in the control panel  Regional and Language Options.  With the time set to h:mm:ss tt, instead of showing AM or PM, the text box displays the "tt" literal.  The display was working correctly in VB4; this problem started just since the upgrade.

Here is the code we are using to get the time format:
    dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buffer, 99)
    myLocale.TimeFormat = LPSTRToVBString(buffer)

    txtTimeS = Format$(Time$, myLocale.TimeFormat)

Does anyone have any idea what is going on or what to do about it?
monacoassociatesAsked:
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.

TaconvinoCommented:
The Format function in VB does not recognize "tt" as a valida date/time format... maybe if you re-write your code like this:

    dl& = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buffer, 99)
    myLocale.TimeFormat = LPSTRToVBString(buffer)

    txtTimeS = Format$(Time$, replace(myLocale.TimeFormat, "tt", "AM/PM"))

+TCV

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
rettiseertCommented:
Also, you can use FormatDateTime function and get the time formated automatically to the system settings:

txtTimeS = FormatDateTime( Time(), vbLongTime )
codeconquerorCommented:
For just use this:

Format$(Now, "H:nn:ss AMPM")


This would produce:

10:45:30 AM
monacoassociatesAuthor Commented:
Thanks for all the good suggestions.  I am going to accept Taconvino's solution as we sell our software internationally.
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.