By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

11th hour failure to trigger click event for object in hash table

P: n/a
Someone else had a question on how to emulate a mouse click. I tried posting
in that thread but I have something of a twist on this problem and I'm
really in trouble here! If I don't get help soon, I'm going to fail this
class and the class is already dragging down my GPA. I'm taking an
introductory visual basic class with an advanced visual basic book and
assignments (the department dropped the prerequisite and the class needs one.
I've taken some programming but this isn't programming and you can't find
the code that you need because half the time the answer isn't even in the
code!)

If this is a dumb question, that's because I'm a student in a 200 level
Visual Basic class. I did try the local help, and search for similar
problems, and look in the book, and ask my school's help desk (none of them
know Visual Basic and the tutoring center is closed)

I'm supposed to make a gomokuo game, including a
computer strategy, as well as a computer random player.

The game board consists of 36 picture boxes. I added them all to a hash table
(BTW, don't know if it matters but the way the keys are set up, the row is
in the tens and the column is in the ones)

I just finished the logic for the computer strategy. I thought the random
player part would be easy.

At the last minute, I tested it and realized that the code that I had to
trigger the
click event subroutine did not work.

The problem is that the sender is supposed to be a member of a hash table. I
need to trigger a sub called "gpic_click," which is the event handler for
the click events of the 36 picture boxes. I need to trigger it with the
correct
picture box (i.e. hashboard(key)) as the sender.

So I need to trigger the click event itself.

I was using hashboard(key).click but that didn't work.

I even tried making a case selection structure

"Select case key
case 11
gpic11.click"
etc.

and that won't even work because the subroutine isn't called gpic11_click
or gpicc25_click, it's one subroutine that handles a lot of click events, and
the instructions were to call the click event handler subroutine for that
particular object and I need to be able to do this without a case selection
structure and 36 copies of the click subroutine.

I just tried duplicating the subroutine and it won't even let me do that!
I can't call a subroutine in the SAME CLASS! It wants an argument and I
have no idea what to put there and it won't tell me and the information is
totally unavaialable and I can't get anyone to help me because everyone's too
good for Visual Basic.

I have a little more than three hours until my academic career, which is the
single most important thing in my life, goes down the toilet because of this!
PLEASE HELP!

TIA
Dec 11 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
LyzH <Ly**@discussions.microsoft.comwrote:
>It wants an argument and I
have no idea what to put there and it won't tell me and the information is
totally unavaialable
At this point we have even less information than you about what that
function is and what argument it expects. At least give us a hint!

--
Lucian
Dec 11 '06 #2

P: n/a
Quite an explanation. Hope there is still some time left... realize "you're
doing it wrong" :-) but this will work.

A click event handler is a function like any other so you can call it
directly. The problem only occurs if you intend to reference the parameters
since a "click event" never happened so clearly what got clicked needs to be
supplied by you.

If your control handler is named gpic_click() it is expecting (I imagine) a
"sender" (System.Object) and an "e" (System.EventArgs). So to simulate a
click on gpic11 you call gpic_click( gpic11, New System.EventArgs)

Good luck.

Tom
"LyzH" <Ly**@discussions.microsoft.comwrote in message
news:4E**********************************@microsof t.com...
Someone else had a question on how to emulate a mouse click. I tried
posting
in that thread but I have something of a twist on this problem and I'm
really in trouble here! If I don't get help soon, I'm going to fail this
class and the class is already dragging down my GPA. I'm taking an
introductory visual basic class with an advanced visual basic book and
assignments (the department dropped the prerequisite and the class needs
one.
I've taken some programming but this isn't programming and you can't find
the code that you need because half the time the answer isn't even in the
code!)

If this is a dumb question, that's because I'm a student in a 200 level
Visual Basic class. I did try the local help, and search for similar
problems, and look in the book, and ask my school's help desk (none of
them
know Visual Basic and the tutoring center is closed)

I'm supposed to make a gomokuo game, including a
computer strategy, as well as a computer random player.

The game board consists of 36 picture boxes. I added them all to a hash
table
(BTW, don't know if it matters but the way the keys are set up, the row
is
in the tens and the column is in the ones)

I just finished the logic for the computer strategy. I thought the
random
player part would be easy.

At the last minute, I tested it and realized that the code that I had to
trigger the
click event subroutine did not work.

The problem is that the sender is supposed to be a member of a hash table.
I
need to trigger a sub called "gpic_click," which is the event handler for
the click events of the 36 picture boxes. I need to trigger it with the
correct
picture box (i.e. hashboard(key)) as the sender.

So I need to trigger the click event itself.

I was using hashboard(key).click but that didn't work.

I even tried making a case selection structure

"Select case key
case 11
gpic11.click"
etc.

and that won't even work because the subroutine isn't called gpic11_click
or gpicc25_click, it's one subroutine that handles a lot of click events,
and
the instructions were to call the click event handler subroutine for that
particular object and I need to be able to do this without a case
selection
structure and 36 copies of the click subroutine.

I just tried duplicating the subroutine and it won't even let me do that!
I can't call a subroutine in the SAME CLASS! It wants an argument and I
have no idea what to put there and it won't tell me and the information is
totally unavaialable and I can't get anyone to help me because everyone's
too
good for Visual Basic.

I have a little more than three hours until my academic career, which is
the
single most important thing in my life, goes down the toilet because of
this!
PLEASE HELP!

TIA

Dec 12 '06 #3

P: n/a
Thanks for getting back to me. Sorry I'm a little panicked.

At this point, I created a different subroutine to do all of the things that
the click routine does. The computer gets its very own subroutine because it
refuses to click.

What the functions are is:
When someone clicks on one of 36 picture boxes (enumerated in the "handles"
clause of the heading of the subroutine)

Change the tag property of the sender. (the tag holds a 0 for empty square,
1 for square controlled by player 1, or 2 for square controlled by player 2)

Change the image displayed by the sender.

In the case of the computermove subroutine that I wrote, the square
corresponding to the key value passed "hashboard(key)" takes the place of
sender. I know that a reference to that works because I use a "for each" to
reset the images when user presses the "new game" button.

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

However, I can't pass anything from the business tier or to the business
tier and it wants me to create a new instance of the business tier every time
I refer to it.

The business tier can access friend declared variables from the presentation
tier (the game board or the opening screen) but a public property of the
business tier is "a non-shared member," as are public variables and subs of
the business tier.

I don't know why but "public" and "friend" don't appear to mean the same
things when I try to use them.

It tells me I need an object reference. I look up object reference and
non-shared member, and the help tells me that, if I have a non-shared member,
I need an object reference. That is so typical of Microsoft's "help."

My book explains nothing. The index contains neither term.

I have 21 minutes. The help desk is saying the lab will be open tomorrow but
there are notices posted _everywhere_ saying that it will not be.

Again, thanks
Lyz
"Lucian Wischik" wrote:
LyzH <Ly**@discussions.microsoft.comwrote:
It wants an argument and I
have no idea what to put there and it won't tell me and the information is
totally unavaialable

At this point we have even less information than you about what that
function is and what argument it expects. At least give us a hint!

--
Lucian
Dec 12 '06 #4

P: n/a
Thanks; that is what I wanted to know.

Now my only problem is to deal with the fact that I have a seperate class
for the
computer strategy and it hangs at the point where it is supposed to call a
public function from that class.

It doesn't throw an exception or anything, it just stops.

Gotta go. Lab closing. Will be open tomorrow, I hope.

Thanks.
"Tom Leylan" wrote:
Quite an explanation. Hope there is still some time left... realize "you're
doing it wrong" :-) but this will work.

A click event handler is a function like any other so you can call it
directly. The problem only occurs if you intend to reference the parameters
since a "click event" never happened so clearly what got clicked needs to be
supplied by you.

If your control handler is named gpic_click() it is expecting (I imagine) a
"sender" (System.Object) and an "e" (System.EventArgs). So to simulate a
click on gpic11 you call gpic_click( gpic11, New System.EventArgs)

Good luck.

Tom
"LyzH" <Ly**@discussions.microsoft.comwrote in message
news:4E**********************************@microsof t.com...
Someone else had a question on how to emulate a mouse click. I tried
posting
in that thread but I have something of a twist on this problem and I'm
really in trouble here! If I don't get help soon, I'm going to fail this
class and the class is already dragging down my GPA. I'm taking an
introductory visual basic class with an advanced visual basic book and
assignments (the department dropped the prerequisite and the class needs
one.
I've taken some programming but this isn't programming and you can't find
the code that you need because half the time the answer isn't even in the
code!)

If this is a dumb question, that's because I'm a student in a 200 level
Visual Basic class. I did try the local help, and search for similar
problems, and look in the book, and ask my school's help desk (none of
them
know Visual Basic and the tutoring center is closed)

I'm supposed to make a gomokuo game, including a
computer strategy, as well as a computer random player.

The game board consists of 36 picture boxes. I added them all to a hash
table
(BTW, don't know if it matters but the way the keys are set up, the row
is
in the tens and the column is in the ones)

I just finished the logic for the computer strategy. I thought the
random
player part would be easy.

At the last minute, I tested it and realized that the code that I had to
trigger the
click event subroutine did not work.

The problem is that the sender is supposed to be a member of a hash table.
I
need to trigger a sub called "gpic_click," which is the event handler for
the click events of the 36 picture boxes. I need to trigger it with the
correct
picture box (i.e. hashboard(key)) as the sender.

So I need to trigger the click event itself.

I was using hashboard(key).click but that didn't work.

I even tried making a case selection structure

"Select case key
case 11
gpic11.click"
etc.

and that won't even work because the subroutine isn't called gpic11_click
or gpicc25_click, it's one subroutine that handles a lot of click events,
and
the instructions were to call the click event handler subroutine for that
particular object and I need to be able to do this without a case
selection
structure and 36 copies of the click subroutine.

I just tried duplicating the subroutine and it won't even let me do that!
I can't call a subroutine in the SAME CLASS! It wants an argument and I
have no idea what to put there and it won't tell me and the information is
totally unavaialable and I can't get anyone to help me because everyone's
too
good for Visual Basic.

I have a little more than three hours until my academic career, which is
the
single most important thing in my life, goes down the toilet because of
this!
PLEASE HELP!

TIA


Dec 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.