Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > General forums > Development
User Name
Password
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-17-2006, 06:34 PM   #1 (permalink)
Big W Powah!
You pussies can -interwebs better than that.
 
Join Date: Jan 2003
Location: Earth
Posts: 1,975
-33 Internets
VB prank help.

Hey. working with Visual Studio.NET 2k3 here, using their Visual Basic editor (classes, yay~)

Anyway, my teacher decided to play a prank on me, so I'm going to play one on her, and I need a bit of help with my code.

Looking for the code which will make the button move when moused over. (I know to use mousehover in the sub, but theres a single line of code that you put inside of the sub to make it move to a random spot on the form, so that you can't click on it)...The code to make it auto-unselect would be nice too, so you can't tab->enter to close the program.

Thanks in advance.
__________________
Lolin Dread Knight
Officer of (Too Much Brown)
Big W Powah! is offline   Reply With Quote
Old 10-17-2006, 09:49 PM   #2 (permalink)
Kallian
CHARLIE DON'T SURF!
 
Kallian's Avatar
 
Join Date: Jul 2004
Posts: 777
+0 Internets
HTML Code:
Dim myRandom As New Random Private Sub Button1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove Button1.Left = myRandom.Next(Button1.Width, Me.Width - Button1.Width) Button1.Top = myRandom.Next(Button1.Height, Me.Height - Button1.Height) End Sub
MouseMove works better than MouseEnter.

Oh, and for the Tab issue, set the button's TabStop property to False.

Also, I have realized that it can go behind controls that are larger than it. Just right click on the button and click, "Bring To Front", after you are done adding controls.

Last edited by Kallian : 10-17-2006 at 10:04 PM.
Kallian is offline   Reply With Quote
Old 10-21-2006, 03:48 PM   #3 (permalink)
Big W Powah!
You pussies can -interwebs better than that.
 
Join Date: Jan 2003
Location: Earth
Posts: 1,975
-33 Internets
Quote:
Originally Posted by Kallian
HTML Code:
Dim myRandom As New Random Private Sub Button1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove Button1.Left = myRandom.Next(Button1.Width, Me.Width - Button1.Width) Button1.Top = myRandom.Next(Button1.Height, Me.Height - Button1.Height) End Sub
MouseMove works better than MouseEnter.

Oh, and for the Tab issue, set the button's TabStop property to False.

Also, I have realized that it can go behind controls that are larger than it. Just right click on the button and click, "Bring To Front", after you are done adding controls.
Thank you. Though I don't think vb 6.0 (what .net2k3 uses) has seperate move/enter on mouse. I think they combined it into mousehover. I'll play around with it and see. Thank you. =)

EDIT: Also, does the variable need to be a class level variable? Going to be putting it in a program I'm going to be turning into her (extra credit for that kinda thing, she finds it hilarious. button1.visible=false was an amusing one. =P), but anyway, yeah, Does it matter if its class-level or control-level? Just curious, want to hide it the best I can.


EDIT: Yeah, mousemove is still there.
__________________
Lolin Dread Knight
Officer of (Too Much Brown)

Last edited by Big W Powah! : 10-21-2006 at 03:57 PM.
Big W Powah! is offline   Reply With Quote
Old 10-21-2006, 08:59 PM   #4 (permalink)
Kallian
CHARLIE DON'T SURF!
 
Kallian's Avatar
 
Join Date: Jul 2004
Posts: 777
+0 Internets
VB 6? I thought you were working with .NET 03?

The variable can either be an instance variable or a local variable. You're not really worried about any kind of performance in this case so it doesn't matter.

Instance variable would be nice because you could get a random number in any function within that class without having to allocate memory (again, if you cared about these types of things).
Kallian is offline   Reply With Quote
Old 10-21-2006, 09:20 PM   #5 (permalink)
Bralkan
Registered User
 
Bralkan's Avatar
 
Join Date: Jan 2002
Location: Atlanta GA
Posts: 2,118
-1 Internets
Send a message via AIM to Bralkan
Kallian is my programming sugar daddy.
__________________
We're all idiots.
http://nottheparrot.blogspot.com
Bralkan is offline   Reply With Quote
Old 10-22-2006, 12:11 AM   #6 (permalink)
Big W Powah!
You pussies can -interwebs better than that.
 
Join Date: Jan 2003
Location: Earth
Posts: 1,975
-33 Internets
Quote:
Originally Posted by Kallian
VB 6? I thought you were working with .NET 03?

The variable can either be an instance variable or a local variable. You're not really worried about any kind of performance in this case so it doesn't matter.

Instance variable would be nice because you could get a random number in any function within that class without having to allocate memory (again, if you cared about these types of things).
Eh. My book/teacher are teaching VB6, but I am using .NET2003 for my editor. I guess I just assumed that it and VB6 were the same thing.

Anyway, thank you again for the help. and yeah, so far I've not made a program bigger than that would fit on a floppy. Simple things like calculations and input validation. Then again, it is intro to programming. I'm a network major, so its not like its -that- important, heh. Just need to know a bit of programming to be able to make an auto-updater and stuff.

I will say knowing how programs work has helped a lot when it comes to understanding what happens when you click on a button.
__________________
Lolin Dread Knight
Officer of (Too Much Brown)
Big W Powah! is offline   Reply With Quote
Old 10-22-2006, 09:38 AM   #7 (permalink)
Kallian
CHARLIE DON'T SURF!
 
Kallian's Avatar
 
Join Date: Jul 2004
Posts: 777
+0 Internets
Where are you obtaining a degree strictly in networking?
Kallian is offline   Reply With Quote
Old 10-22-2006, 10:04 AM   #8 (permalink)
Big W Powah!
You pussies can -interwebs better than that.
 
Join Date: Jan 2003
Location: Earth
Posts: 1,975
-33 Internets
Quote:
Originally Posted by Kallian
Where are you obtaining a degree strictly in networking?
ITT Tech. Computer Sciences Degree with a specailization in Networking.
__________________
Lolin Dread Knight
Officer of (Too Much Brown)
Big W Powah! is offline   Reply With Quote
Old 10-22-2006, 01:25 PM   #9 (permalink)
Kallian
CHARLIE DON'T SURF!
 
Kallian's Avatar
 
Join Date: Jul 2004
Posts: 777
+0 Internets
Quote:
Originally Posted by Big W Powah!
ITT Tech. Computer Sciences Degree with a specailization in Networking.
Good luck to you sir.
Kallian is offline   Reply With Quote
Old 10-22-2006, 04:55 PM   #10 (permalink)
Big W Powah!
You pussies can -interwebs better than that.
 
Join Date: Jan 2003
Location: Earth
Posts: 1,975
-33 Internets
Quote:
Originally Posted by Kallian
Good luck to you sir.
Thank you. To you as well sir.

(I feel pretty good about it, considering the ammount of companies we have in and out of our building hiring about-to-graduate students.)
__________________
Lolin Dread Knight
Officer of (Too Much Brown)
Big W Powah! is offline   Reply With Quote
Old 10-22-2006, 11:36 PM   #11 (permalink)
Zippygoose
Math Enthusiast/Badass MC
 
Zippygoose's Avatar
 
Join Date: Jun 2002
Location: Seattle
Posts: 592
-1 Internets
Send a message via AIM to Zippygoose
It's good that you aren't using the fully integrated 2k3 (or even moreso 2k5) versions of VB/C# for an intro class. You'll learn a whole lot more writing all of the code vs. dragging and dropping controls via the toolbox. It's a godsend though when you start writing custom event handlers, validation and a DAL.
__________________
Join the FoH stock market game


Last edited by Zippygoose : 10-22-2006 at 11:39 PM.
Zippygoose is offline   Reply With Quote
Old 10-23-2006, 08:16 AM   #12 (permalink)
Big W Powah!
You pussies can -interwebs better than that.
 
Join Date: Jan 2003
Location: Earth
Posts: 1,975
-33 Internets
Quote:
Originally Posted by Zippygoose
It's good that you aren't using the fully integrated 2k3 (or even moreso 2k5) versions of VB/C# for an intro class. You'll learn a whole lot more writing all of the code vs. dragging and dropping controls via the toolbox. It's a godsend though when you start writing custom event handlers, validation and a DAL.
Actually, intro uses the toolbox, advanced VB teaches hand-writing subs.
__________________
Lolin Dread Knight
Officer of (Too Much Brown)
Big W Powah! is offline   Reply With Quote
Old 10-23-2006, 08:18 AM   #13 (permalink)
Kallian
CHARLIE DON'T SURF!
 
Kallian's Avatar
 
Join Date: Jul 2004
Posts: 777
+0 Internets
Quote:
Originally Posted by Big W Powah!
Actually, intro uses the toolbox, advanced VB teaches hand-writing subs.
The way it should be. Intro students shouldn't be forced to write handlers for controls.
Kallian is offline   Reply With Quote
Old 10-23-2006, 10:56 AM   #14 (permalink)
Zippygoose
Math Enthusiast/Badass MC
 
Zippygoose's Avatar
 
Join Date: Jun 2002
Location: Seattle
Posts: 592
-1 Internets
Send a message via AIM to Zippygoose
IMO it's important for beginners to understand at the very least what the native handlers are doing, even if they aren't using them in any way. Otherwise they are just these mysterious "things" being passed into your event methods that VS is generating for you.

Writing your own subs/methods is also helpful in understanding how everything is tied together. While it's nice to double click a button in your designer view and be taken to an auto-generated onclick event method, there is some value in knowing everything that went into the process (like wiring up those events).

You are talking to a pure software guy though, perhaps you are right in regards to a basic programming class intended for network admins/hardware guys /shrug
__________________
Join the FoH stock market game

Zippygoose is offline   Reply With Quote
Old 10-23-2006, 11:53 AM   #15 (permalink)
Big W Powah!
You pussies can -interwebs better than that.
 
Join Date: Jan 2003
Location: Earth
Posts: 1,975
-33 Internets
Quote:
Originally Posted by Zippygoose
IMO it's important for beginners to understand at the very least what the native handlers are doing, even if they aren't using them in any way. Otherwise they are just these mysterious "things" being passed into your event methods that VS is generating for you.

Writing your own subs/methods is also helpful in understanding how everything is tied together. While it's nice to double click a button in your designer view and be taken to an auto-generated onclick event method, there is some value in knowing everything that went into the process (like wiring up those events).

You are talking to a pure software guy though, perhaps you are right in regards to a basic programming class intended for network admins/hardware guys /shrug
The intro class is shared among Programming and Network Students...We have however, covered what those double-click auto-generated subs do. Thats all in lecture/note taking though.
__________________
Lolin Dread Knight
Officer of (Too Much Brown)
Big W Powah! is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
uberguilds network



All times are GMT -7. The time now is 03:13 PM.


Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6