![]() |
|
![]() | ||
|
Subject:
How to collect random bits on mouse movements in Visual Basic?
Category: Computers > Programming Asked by: bv6-ga List Price: $50.00 |
Posted:
28 Sep 2002 21:33 PDT
Expires: 28 Oct 2002 20:33 PST Question ID: 70313 |
Hello, I am looking for a good example of code to collect random bits on mouse movements. I am using Visual Basic 6. By moving mouse on the form I need to collect about 100 bits of random numbers on the timer (firing every second or less). All 100 bits I need to write to the collection (as a string?). I will really appreciate if somebody can do it for me. Thanks, BV6 |
![]() | ||
|
There is no answer at this time. |
![]() | ||
|
Subject:
Re: How to collect random bits on mouse movements in Visual Basic?
From: sherlockh-ga on 30 Sep 2002 14:44 PDT |
If you want to obtain the mouse position many times a second, you could use the 'mouse move' procedure. ie. in the code for the 'form', select 'MouseMove'. That will give you a procedure which gives you the X and Y coordinates of the mouse cursor on the form. This procedure will be called many times a second (as long as the mouse is moving), so there's no need to use a timer. But if you wanted to use a timer and only check the mouse position a specified number of times a second, you could set global variables to the values of the mouse's X & Y position, then use these in the timer function (eg. you could add the X & Y values to an array of X & Y values in the every tenth of a second or so in the timer function). When you say you want to write '100 bits to a collection', do you actually mean bits (eg. binary digits, ie. 1 or 0?) or just 100 numbers? To add 100 numbers to a collection, you could create an ARRAY of integers. eg. Dim numbers(100) as integer The mouse movements may not be very random though, especially if the mouse is moved only very slowly. Also, the maximum size of the numbers you get will depend on the size of the form. If you want the numbers to be a bit more random, you could use the randomize function (eg. seed the random number generator with the mouse positions), then use the rnd function (to generate random numbers). To get a 'random bit' from the mouse position (if you mean 1 or 0), you could say something like, if the X mouse position is even, set a variable to 0, otherwise set a variable to 1. eg. if x mod 2=0 then number=0 else number=1 If the above isn't quite what you meant, please give further details on what you meant and I'll try and give a better method |
Subject:
Re: How to collect random bits on mouse movements in Visual Basic?
From: bv6-ga on 01 Oct 2002 11:02 PDT |
Thank you sherlockh for your help. I think I got a clear idea what should I do. I can not figure out here how to rate a question, but I would give you 5 stars for the comment. Thank you! |
Subject:
Re: How to collect random bits on mouse movements in Visual Basic?
From: bookface-ga on 03 Oct 2002 20:49 PDT |
He generously answered your question for free as a comment, which is why you cannot rate his answer; though, come to think of it, someone should propose that as an option to the Google! Answers management. Additionally, most security-focused programs get their randomized input from users by examining the time between inputs; it is something that can be measured very very precisely and is in such small increments that it is impossible (for all intents and purposes) to duplicate. The direction of movement, of course, can be added as additional randomness per movement, but I think it is probably best to get all your numbers from timings. |
Subject:
Re: How to collect random bits on mouse movements in Visual Basic?
From: omniscientbeing-ga on 04 Oct 2002 07:17 PDT |
I agree with sherlockh-ga's approach on how to accomplish the program, and also that, for a (free) comment, bv6-ga is getting quite a deal on his Question. However, the Question does state that s/he is looking for "a good example of code," and since it's priced at $50, I'd say that if sherlockh-ga's Comment were an Answer, it would fall somewhat short of completely answering the question since there is no code given. Perhaps I could whip this program up in VB6 along the lines of what sherlockh-ha has outlined, and then post the source code as an Answer. Would you be interested in this, or has the Comment already helped you out enough to where you wouldn't feel the need to pay $50? Note: This thorough technical design description vs. "live code" answer is a common dilemma when answering technical questions. Yes, sherloch-ga basically gives you the design on how to do it, which, for a Comment, is more than you could ask for, but there's no actual code which the fairly priced quesion asks for. A single answer which gives BOTH a thorough technical design descripion and live, working source code would be worth more than $50 in my opinion, although that doesn' mean you won' get it, especially with the high quality of free comments. ~omniscienbeing-ga |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |