Please help Userform TextBox1 format appear in hh:mm:ss AM/PM format.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi,

Please help. Below is my current code.
I want the TextBox1 to show time format in hh:mm:ss AM/PM format.
When i run the it show in general number format.
Thanks


Code:
Private Sub TextBox1_Change()
  TextBox1.Value = Range("DigitalClock").Value
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I came up with something funny & it never worked...
Code:
Private Sub TextBox1_Change()
Dim i As Integer
  i = TextBox1.Value
  Range("DigitalClock").Value = TextBox1.Value
  Text.NumberFormat = "hh:mm:ss AM/PM"
  
End Sub
 
Upvote 0
I came up with something funny & it never worked...I just want TextBox1 format to show "hh:mm:ss AM/PM" everytime.... :biggrin:

Might be weird but can be posible...

Code:
Private Sub TextBox1_Change()
Dim i As Integer
  i = TextBox1.Value
  Range("DigitalClock").Value = TextBox1.Value
  Text.NumberFormat = "hh:mm:ss AM/PM"
 
End Sub
 
Last edited:
Upvote 0
Try.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> TextBox1_Change()<br>  TextBox1.Value = Time<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Or if you are experementing with formating Try.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> TextBox1_Change()<br>  MyStr = Format(Range("DigitalClock"), "hh:mm:ss AMPM")<br>  TextBox1.Value = MyStr<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Brian, thank you for helping. I dont what I am doing wrong here....
the format shows correcly now but even though when range "DigitalClock" is showing a running clock it does not show in userform textbox1


What could be the problem:confused:

Pedie

current
Code:
Private Sub TextBox1_Change()
  Range("DigitalClock").Value = TextBox1.Value
  TextBox1.Value = Time
End Sub
 
Upvote 0
Sorry Pedie

I should have explained, I am very lazy, I have posted two possible solutions.
We were cross posting on the second one, use either code separately.
The first one doesn't need the "DigitalClock", it shows the system time.
 
Upvote 0
Brian, i understand...it can be a vey lazy day...:biggrin:

I tried it this way...it is showing time format...but the second does not tick..even though i can see that the DigitalClock range in ticking which is located on cell A1.

:confused:

If you're lazy...you can answer some other time thats okay:biggrin:
 
Upvote 0
Hi pedie

I don't think that you can do that, using textbox change event.
It only changers when you manually change the value of the textbox.
Try it yourself, use one of the codes, and with the Digital Clock ticking click in the textbox.
Then press the backspace key every couple of seconds, and you will see the textbox value change.
There might be ways around it.
Are you using textbox on a form, or embedded onto a sheet?
Please post the code for Digital Clock,that you are using, better still a link to the place where you got the code from.

EDIT: You have got me interested now, please answer the two questions above, and post the solution. Thanks
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top