Reputation: 10913
How do I get the system time using VB.NET and copy it into the clipboard automatically?
Is there a built-in function in VB.NET for this?
Upvotes: 3
Views: 32207
Reputation: 754715
I'm not sure what you mean by System Time, but if it's just the string representation of the current time then you can do the following.
ClipBoard.SetText(DateTime.Now.ToString())
This code will work in both Windows Forms and WPF.
Upvotes: 5
Reputation: 1
Better use the DateTime.UtcNow
method.
It returns time without local format and DST offset.
UTC
will keep you out of trouble when storing data.
You can always format to local when export/display is needed.
Upvotes: 0
Reputation: 22368
Use DateTime.Now to get the time and Google for the code to copy to the clipboard.
Or take a look at this post.
Upvotes: 0