PDA

View Full Version : Default Date (today) in a text box (VB)


CdnGal
03-04-2003, 05:34 AM
Hi, All

I can't seem to find help on this hopefully "simple" problem. (I'm a newbie) I'm using VB, and the pages I'm using are .asp pages. All I want to do is when my form is presented to the user to fill in, I want the date (today's date) to appear so they don't have to fill it in. Can someone tell me how to do this. All I can find is big blocks of code, and think it should be MUCH easier than this. Here's part of my code. The page functions fine, all I want is to have today's date appear in the text box where the date would normally be filled in by the user.

Thanks!


<form name="frmSPLAddData" method="GET" action="logbooksave.asp">
<table>

<tr>

<td align=right>Date (MM/DD/YY):</td>

<td><input type="text" name="txtQ1" size="15" value='' tabindex="1"></td>

</tr>
<tr>
<td align=right>Name</td>
<td><input type="text" name="txtQ2" size="15" tabindex="2"></td>
</tr>
<tr>

vickers_bits
03-04-2003, 05:52 AM
<% Date() %>
will return server date
(may not be in the form MM/DD/YY)

<% Month(Date) & "/" & Day(Date) & "/" & Year(Date) %>
will return MM/DD/YYYY

<%="<input type=""hidden"" id=""date_today"" value=""" & Date() & """ />"%>

if you put the date in a textbox the user can change it at will

glenngv
03-04-2003, 07:45 AM
why make it harder to read when you can simply make it like this?

<input type="text" name="txtQ1" size="15" value="<%=Date()%>" tabindex="1">

CdnGal
03-06-2003, 07:38 AM
Thank you Glenn....solved! Again!

mayer1508
09-18-2007, 04:55 AM
why make it harder to read when you can simply make it like this?

<input type="text" name="txtQ1" size="15" value="<%=Date()%>" tabindex="1">
Hey Glenn,

I am relitivly new (very new!) to Vb. Have created some simple forms for an excel file.

One of the text boxes is for the user to enter the current date. I simply want the current date to automatically appear there. Tried this and cant seem to get ti to work. Have looked everywhere!

Any help would be creately appreciated.

Currently the code for that specific text box looks like this:

Private Sub Dates2_Change()
Format "dd/MM/yyyy"
End Sub

Any help???????????????/

Mick