Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Oct 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Userforms (VBA Excel '97)

    1) I have created a userform to input data, but i wish to stop people useing a full stop for dates. I.e 16.01.02 instead of 16/01/02 for 16th January 2002, is there anyway i can either use VBA so that as soon as they exit the textbox it changes the . to / or to use VBA to see if the textbox contains . and throw up an error message of my design????

    2) I wish to automatically have the 1st of the current month input into a textbox when the userform in initialised, does anyone know how to do this???


    Please help!

  2. #2
    New Lounger
    Join Date
    Oct 2001
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Userforms (VBA Excel '97)

    Come on guys, it seems to be a rather simple problem??? PLEASE Help

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Userforms (VBA Excel '97)

    2 hours isn't long to wait...

    For your first question, you might like to use something like

    <pre>Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If KeyAscii = Asc(".") Then KeyAscii = Asc("/")
    End Sub
    </pre>


    You may also want to put in checks for Alphabetic characters or other things that aren't date-like.

    For your second question, a quick search of this forum (for the string "Month") would have led you to <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=acc&Number=100995&fpart=1#P ost100995>this thread</A>, which gives the elegant...
    <pre>Private Sub UserForm_Activate()
    TextBox1.Text = Date - Day(Date) + 1
    End Sub
    </pre>


    StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •