Sometimes it may be useful to have a hotspot that automatically fills in a date field with the current date. For example, perhaps your form requires the filler to record the date on which they are filling it out. This process can easily be made more automated by using a hotspot that automatically records the date for them.

Creating the Hotspot

Unsurprisingly, the first step to creating a current date hotspot is to create the hotspot itself. For sake of this explanation, we will use a basic form that has a CText field formatted for a MM/DD/YYYY date value and a button next to it that has the hotspot to get the date.

With the hotspot created, you should go ahead and add the AfterInkAdded event handler to your script code. This explanation will focus on VB.NET scripting.

Getting the Date

Inside the event handler, you should now write the code that gets the current date and formats it properly in MM/DD/YYYY format. The code below will work for that purpose.


Dim todaysDate As Date = Date.Today
Dim todayString As String = todaysDate.ToString("MM/dd/yyyy")


This code will store the current date in a MM/DD/YYYY format to a string, todayString.

Using the Date

With the todayString variable, you can now use the date in a variety of ways. The most common way would be to set a field's value to that string. In our example, we have a CText field that we want to store the current date. Doing so requires only a single line more of code:


_Date.Value = todayString


Now, when the user clicks the "Get Date" button/hotspot, the CText field will store the date.