2 Replies - 4171 Views - Last Post: 10 September 2009 - 07:36 AM Rate Topic: -----

#1 marxman89  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 09-July 09

how to make an input to accept only a date?

Posted 10 September 2009 - 02:20 AM

let's say that there are 2 input boxes: txtbox1 and txtbox2

if a user enter a value other than date with format mm/dd/yyyy then a messagebox "INPUT MUST BE DATE ONLY" should prompt.

here's a part of my code:

if txtbox1.text or txtbox2.text= (what should i put here for the txtbox1 and txtbox 2 to accept only a date value???)

then

msgbox("INPUT MUST BE DATE ONLY")

end if

Is This A Good Question/Topic? 0
  • +

Replies To: how to make an input to accept only a date?

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: how to make an input to accept only a date?

Posted 10 September 2009 - 05:47 AM

why to use textboxes when you can use DTPicker :) use "Microsoft Windows Common Controls - 2 6.0 (SP4) -> MSCOMCT2.OCX" it is standart OCX there is DTPicker Control that can select date so you dont need to check if the user write date in the textbox.
good luck :)

This post has been edited by NoBrain: 10 September 2009 - 07:36 AM

Was This Post Helpful? 1
  • +
  • -

#3 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: how to make an input to accept only a date?

Posted 10 September 2009 - 07:36 AM

onother way error hendler

the cdate() function will generete error and will go to error hendler

private function somefunc()
  on error goto err_h
  str1=cdate(textbox1.text)
  str2=cdate(textbox2.text)
  exit function
err_h:
msgbox("INPUT MUST BE DATE ONLY")
end fucntion



good luck

This post has been edited by NoBrain: 10 September 2009 - 07:36 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1