How can I get the system time to display within a text box, I'm writing an application that looks at the system time and compares it with the time from another device. Then I want to be able to update the the other device with the system time if there is a difference. I can't seem to be able to get the system time to display though in the text box.
Any help would be greatly appreciated.
Thanks in advance

Displaying System Time in Text Box
gifa
Hi thanks but I know about DateTime.Now and have tried to use it but it will not display within the text box, I'm looking for someone to show me the full piece of code please so I can see what I'm doing wrong.
Many thanks
AJAX HAL
DateTime.Now will tell you the time on the local machine. You can then call one of a number of methods to format that as a string.
raxe
Just reiterating what cgraus had said.
Drop a timer control on a form called timer1 and the following code will cause the textbox to become a clock, updating every second.
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Textbox1.Text = Now.ToLongTimeString
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Start()
End Sub
End Class
LV_DP
jayson.gm.ds2.ci.ftsp
Hi,
Try this:
Public
Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadTextBox1.Text =
CStr(Now)
End SubEnd
ClassRon
derekyeong
Textbox1.Text = DateTime.Now.ToShortTimeString()
I suspect you know that too ( I certainly said it in my original reply ). Is the problem that you want to show the ONGOING time If so, you need to set a timer, which you can do by dragging it onto your form, and then in it's tick event, do the above. You need to set it's interval to be < 1000 to make sure it updates at least once a second, I'd go for 500.
ScaryJerry