Jumat, 19 September 2014

Re: [ExcelVBA] Preventing keyboard use before userform shows

 



That's OK.  Now all you need to do is write the user form initialize code so that it clears the text box as the form starts to show.  An example can be found here: http://www.excel-easy.com/vba/userform.html

Regards, Dave S
 
----- Original Message -----
Sent: Friday, September 19, 2014 7:24 PM
Subject: Vedr: [ExcelVBA] Preventing keyboard use before userform shows


When I run this code and while the sound is playing (3-5 Seconds) I try to write some numbers on the keyboard, they appear in the textbox when the userform shows.

Torstein



Den Fredag, 19. september 2014 11.04 skrev "'David Smart' smartware.consulting@gmail.com [ExcelVBA]" <ExcelVBA@yahoogroups.com>:


 

> ... but it doesn't seems to work
 
What do you mean by this?  What precisely happens?

Regards, Dave S
 
----- Original Message -----
Sent: Friday, September 19, 2014 6:39 PM
Subject: Vedr: [ExcelVBA] Preventing keyboard use before userform shows

Thank you, David but it doesn't seems to work:

This is my code

Sub testuserform()
sndPlaySound32 "soundfile.wav", SND_SYNC
 
 UserForm1.Show
 
End Sub

My next appraoach is making a userform with two textboxes. I make the first one with invisible text.
When I open this it seems to be empty, but it still have focus. Can I after showing the userform make it change focus to the next textbox, being ready for the user to input his answer there.

How can I change focus - that is move the cursor (without having the user click or hitting TAB?

Regards

Torstein




Den Fredag, 19. september 2014 8.57 skrev "'David Smart' smartware.consulting@gmail.com [ExcelVBA]" <ExcelVBA@yahoogroups.com>:


 

Have you tried telling the sound procedure to wait until the sound finishes before continuing code execution?  (I.e. second parameter of SND_SYNC.)
 
This should delay the creation/display of the user form, which would mean that the user wouldn't be able to type in the textbox, because it wouldn't exist yet.

Regards, Dave S
 
----- Original Message -----
Sent: Friday, September 19, 2014 4:33 PM
Subject: Vedr: [ExcelVBA] Preventing keyboard use before userform shows

Hi Paul and thank you for your answer, but this did not help me.

My English may prevent me from explaining this well, but to delay the userform with a wait-statement does not prevent the user from using the keyboard, writing the numbers before the userforms shows. And when it shows this numbers are in the textbox. In that way I can't test whether they remember the numbers.

Can I delete the keyboard buffer in an easy way before the userform is shown, or can I delete any content in the userform textbox before the userform is shown?

Thanks again!

Torstein


Den Torsdag, 18. september 2014 12.33 skrev "Paul Vermeulen paul.vermeulen@vulcantech.com.au [ExcelVBA]" <ExcelVBA@yahoogroups.com>:


 
Hi Torstein
 
The code to display the form executes as soon as the computer asks the sound to start playing, not necessarily when the sound has finished playing.
 
Many ways to do this, but just insert a wait statement Application.Wait (Now() + "00:00:02") or use "sleep" as per http://www.ozgrid.com/forum/showthread.php?t=89193
 
 
Paul
 
 
From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com]
Sent: Thursday, 18 September 2014 4:43 PM
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] Preventing keyboard use before userform shows
 
I'm making a memory test in Excel.
 
I play a sound With some numbers and I want the user to Write the numbers in a userform after the sound have been played.
 
But now the user is able to Write the numbers while the sound is playing, then this numbers appears in the one and only textbox I have in the userform.
 
Can I prevent this?
 
Here is my code:
 
sndPlaySound32 "D:\data-filer\data\yrkespsyk\tallhukommelse\lyder\" & lydfilnavn, 0&
 
 UserForm1.Show
 
Thanks in advance
 
Torstein
 


No virus found in this message.
Checked by AVG - http://www.avg.com/
Version: 10.0.1432 / Virus Database: 4015/7732 - Release Date: 09/18/14


No virus found in this message.
Checked by AVG - http://www.avg.com/
Version: 10.0.1432 / Virus Database: 4015/7738 - Release Date: 09/19/14



No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1432 / Virus Database: 4015/7738 - Release Date: 09/19/14

__._,_.___

Posted by: "David Smart" <smartware.consulting@gmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)

Improvements in Yahoo Groups Search
Searching for new groups to join is easier than ever. We've honed our algorithm to bring you better search results based on relevance and activity. Try it today!

----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar