Click here to Skip to main content
15,887,267 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: help to use outlook express in coding Pin
Paul Conrad29-Dec-07 6:53
professionalPaul Conrad29-Dec-07 6:53 
QuestionDisabling keyboard access in dataGridView? Pin
Benny_Lava28-Dec-07 22:39
Benny_Lava28-Dec-07 22:39 
GeneralSecurity levels/user access control in windows form application Pin
tellytub28-Dec-07 18:19
tellytub28-Dec-07 18:19 
GeneralRich Text Box query: embedding SQL record id's in text Pin
Ned Rifle28-Dec-07 17:06
Ned Rifle28-Dec-07 17:06 
General911 Emergency - Lost in the sauce Pin
Dee Kay28-Dec-07 16:34
Dee Kay28-Dec-07 16:34 
GeneralRe: 911 Emergency - Lost in the sauce Pin
MikeMarq28-Dec-07 21:34
MikeMarq28-Dec-07 21:34 
GeneralRe: 911 Emergency - Lost in the sauce Pin
Dee Kay29-Dec-07 2:22
Dee Kay29-Dec-07 2:22 
GeneralRe: 911 Emergency - Lost in the sauce Pin
MikeMarq29-Dec-07 7:07
MikeMarq29-Dec-07 7:07 
I think I understand what is wrong here but please let me know if my guess about your intentions is incorrect.

It looks like you're drawing a false analogee between how c/c++ handles events and how vb handles events. There is no reason I can see that you would need a loop at all and it looks like you are trying to treat your subroutine as if it was main in c/c++. In c/c++ execution starts at main and events are handled one of 2 ways: either there is an infinate loop that is interrupted with an interrupt or you use some library function that stops execution. For instance scanf will stop and wait for you to make an input.

VB doesn't work that way. Nothing that I am aware of waits for inputs and there is no main. It looks like you are expecting your inputbox to work like a scanf. What will happen in vb is that the program will immediately read your inputbox then go immediately to the next line of code regardless. Everytime you do something vb looks for a subroutine that matches the event and if it finds one it call that sub and goes till it finishes execution. In general I think you are making your code way more complicated than it needs to be.

Lets get specific, you are getting an infinate loop it looks like because it looks like the assignment of random to input probably never executes because it is nested in a case that never executes. Therefore your loop always test something other than random. But to be honest I don't think you need a loop at all.

I might be misunderstanding your project cause I don't understand the logic of some of your code. But if I am understanding it correctly I would do it like below.

dim inputnum as integer, randomnum as integer<br />
<br />
'create a random number<br />
inputnum = textbox1.text<br />
if inputnum > randomnum then<br />
'move picture up<br />
elseif inputnum < randomnum then<br />
'move picture down<br />
else 'they're equal<br />
'game is done<br />
end if



ps if you have option strict on you may need to do some casting on this statement inputnum = textbox1.text but I'm not sure.
GeneralRe: 911 Emergency - Lost in the sauce Pin
Dee Kay29-Dec-07 12:59
Dee Kay29-Dec-07 12:59 
GeneralRe: 911 Emergency - Lost in the sauce Pin
Dee Kay29-Dec-07 15:32
Dee Kay29-Dec-07 15:32 
GeneralRe: 911 Emergency - Lost in the sauce Pin
MikeMarq29-Dec-07 20:21
MikeMarq29-Dec-07 20:21 
GeneralPutting .ico files on buttons Pin
Benny_Lava28-Dec-07 2:12
Benny_Lava28-Dec-07 2:12 
GeneralRe: Putting .ico files on buttons Pin
eyes200728-Dec-07 2:49
eyes200728-Dec-07 2:49 
GeneralRe: Putting .ico files on buttons Pin
Paul Conrad28-Dec-07 11:00
professionalPaul Conrad28-Dec-07 11:00 
GeneralRe: Putting .ico files on buttons Pin
Sun Rays28-Dec-07 22:21
Sun Rays28-Dec-07 22:21 
Generalprinting a different report Pin
eyes200728-Dec-07 1:41
eyes200728-Dec-07 1:41 
GeneralRe: printing a different report Pin
jhoga28-Dec-07 3:53
jhoga28-Dec-07 3:53 
Questionhelp help Pin
Member 475249028-Dec-07 1:32
Member 475249028-Dec-07 1:32 
GeneralMultiple violations! Pin
leckey28-Dec-07 5:14
leckey28-Dec-07 5:14 
GeneralRe: Multiple violations! Pin
Paul Conrad28-Dec-07 10:59
professionalPaul Conrad28-Dec-07 10:59 
GeneralRe: Multiple violations! Pin
leckey28-Dec-07 11:11
leckey28-Dec-07 11:11 
QuestionShowing custom controls? Pin
Benny_Lava27-Dec-07 22:36
Benny_Lava27-Dec-07 22:36 
AnswerRe: Showing custom controls? Pin
Dave Kreskowiak30-Dec-07 7:59
mveDave Kreskowiak30-Dec-07 7:59 
GeneralCannot open View Designer in Visual Studio Pin
Meenge27-Dec-07 20:21
Meenge27-Dec-07 20:21 
GeneralRe: Cannot open View Designer in Visual Studio Pin
Paul Conrad30-Dec-07 10:41
professionalPaul Conrad30-Dec-07 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.