Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
On click and finding the object/component clicked on Posted by pdunn on 17 Sept 2008 at 2:52 AM
I am programming in Access and there are over 60 text boxes all that start with txtTime_##. The program needs to set the value as the current time when clicked. It's fine and dandy to make 60+ txtTime_##_Click() txtTime_##.Value = Now. However, I believe there should be a less time consuming way to do this. There should be a general Click method that captures the clicking of the mouse, correct. Then find out the name of the component that was clicked and if the name has txtTime_ then place now inside of component name. I do not know how to accomplish the general case.

Thank you for any help.
Report
Re: On click and finding the object/component clicked on Posted by Barkeeper on 17 Sept 2008 at 5:56 AM
A Control-Array is your friend, but i don't know if Access/VBA supports Control-Array. VB does. Excel doesn't.

In classic VB you would create a Control-Array containing your 60+ Textboxes. You would have to code the Click-Event only one Time:
Private Sub txtTime_Click(Byval Index as Integer)

txtTime(Index).Text=Now

End Sub


as a sidenote: Textboxes have a "Text"-Property, not "Value"

: I am programming in Access and there are over 60 text boxes all that
: start with txtTime_##. The program needs to set the value as the
: current time when clicked. It's fine and dandy to make 60+
: txtTime_##_Click() txtTime_##.Value = Now. However, I believe there
: should be a less time consuming way to do this. There should be a
: general Click method that captures the clicking of the mouse,
: correct. Then find out the name of the component that was clicked
: and if the name has txtTime_ then place now inside of component
: name. I do not know how to accomplish the general case.
:
: Thank you for any help.

------------------------------------------
Only stupidity of mankind and the universe
are infinite, but i'm not sure concerning
the universe. A. Einstein



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.