Need help with Time/Date
Im making a form just like NOTEPAD. In my MenuItems I have one for Time/Date. I need to know how I can add the Time & Date in the actual position using the property of SelectionStart. I have to use "Insert ()"to insert the hour & date in the actual cursor postion. I know that NOW has the methods for ToShortTimeString & ToShortDateString to extract the hour & date separately in the system, but don't know well how to use them.
Can Someone give an example. For the text display in the form im using a textbox (txtContents).
[538 byte] By [
Zumbate] at [2007-11-11 7:13:53]

# 1 Re: Need help with Time/Date
You could do this:
With txtBox
.Text = .Text.Insert(.SelectionStart, DateTime.Now.ToString())
End With
But that merely inserts the date at the current cursor position. It does not replace the selected text with the date, as I would expect if I selected some text and then clicked "Insert Date."
This code, while kludgy, is the simplest way to accomplish the expected behavior:
txtBox.Focus()
SendKeys.Send(DateTime.Now.ToShortDateString())
# 2 Re: Need help with Time/Date
string time = DateTime.Now.ToShortTimeString() gets you a string with the current time.
string date = DateTime.Now.ToShortDateString() gets you a string with the current date.
You can just add these string using your insert() method.
Hope it helps