need to jump to the start of my forms code...

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I need to be able to jump to the start of my code if a particular radio button is not pressed. How do I this??? The goto line1 does not work?

Any ideas?

Scott

If Not RadBut4.Checked Or RadBut5.Checked Then

MsgBox("Please choose Annual or Single Trip")

'GoTo Line1 goto start needed...
 
Scott said:
I need to be able to jump to the start of my code if a particular radio
button is not pressed. >How do I this??? The goto line1 does not work?
\\\
Line1:
///

If Not RadBut4.Checked Or RadBut5.Checked Then

MsgBox("Please choose Annual or Single Trip")

'GoTo Line1 goto start needed...

You will have to create a label in order to jump to a certain position.
 
Scott said:
OK I will do that, how will I code it?

As I said, prefix the first line with 'Line1:' and call 'GoTo Line1' to jump
to the "label" 'Line1'.
 
Scott,

First you have give the user change to check it, this will only get a loop
and a crazy user. Probably you have seen those AVI's from a user jumping on
his srcreen and other like that.

So you set this in a windows.forms.timer (you can drag that from the
toolbox).
Start from the toolbox the event from that and set it to enabled when needed
and than an timer where you set the interval to 10 or something so it fires
direct.

http://msdn.microsoft.com/library/d...ml/frlrfSystemWindowsFormsTimerClassTopic.asp

Than in that event something as

mytimer.enabled = false
If Not RadBut4.Checked Or RadBut5.Checked Then
MsgBox("Please choose Annual or Single Trip")
mytimer.interval = 4000
'dont set it to low a user has to be able to do something, he has to click
this button and to set the button
mytimer.enabled = true 'when you dont do it like this it goes on
firing.
end if

I hope this helps?

Cor






..
 
How about this:

If Not RadBut4.Checked or RadBut5.Checked Then
MsgBox("Please choose Annual or Single Trip")
Exit Sub
Else
' whatever you are doing if they do the above
End If
(or you can just leave out the Else statement and just use, End If and afte that point the rest of your code in the sub.)

That will put your user back to the beginning. Not like GoTo Line 1 in Quick Basic etc. but, it will EXIT the Sub you are in
(after your user Clicks OK in the MessageBox) and then they can start over at the point they entered the wrong
data........(unless you have had them entering a lot of stuff prior to this.....depends on the rest of your code)
james

I need to be able to jump to the start of my code if a particular radio button is not pressed. How do I this??? The goto line1
does not work?

Any ideas?

Scott

If Not RadBut4.Checked Or RadBut5.Checked Then

MsgBox("Please choose Annual or Single Trip")

'GoTo Line1 goto start needed...
 
Hi Scott

Despite all the previous answers, please consider the following construct:

Do
Test for Success

If AllIsWell Then
Exit Do
Endif
Loop

This would the structured answer to your question.

HTH

Charles


I need to be able to jump to the start of my code if a particular radio
button is not pressed. How do I this??? The goto line1 does not work?
Any ideas?
Scott
If Not RadBut4.Checked Or RadBut5.Checked Then
MsgBox("Please choose Annual or Single Trip")
'GoTo Line1 goto start needed...
 
Charles,

You this was of course my first thought and answer and than I looked at the
code.

I tried to find that video from that guy who was first hitting and than
broke his screen.

This will in my opinion give and endless popup screen.

:-)

Cor
 
Hi Cor

I'm not sure that I follow you. The intention is that if AllIsWell then the
code will exit the loop, and no more pop-up screen. If the test involves
looking at a radio button, then isn't this effectively what the OP asked
for?

Charles
 
Charles,

Or do we misunderstand each other.

What is the effect from this code

Do
If Not RadBut4.Checked Or RadBut5.Checked Then
MsgBox("Please choose Annual or Single Trip")
Exit Do
Endif
Loop

Cor
 
But that is not what I wrote. I was illustrating a construct. What you have
written is the equivalent of

Do
If Not AllIsWell Then
Exit Do
Endif
Loop

?

Charles
 
Charles,

This is what you wrote
Do
Test for Success
If AllIsWell Then
Exit Do
Endif
Loop

What triggers that test, that is a user screen action, however he has no
time to change that because that loop will surely be quicker than his typing
action. It stays in that loop, therefore I made that sample with the timer
in it. (And than that loop is not needed anymore)

However I can be wrong of course, just how I see this.

Cor
 
Cor

Clearly the construct I am illustrating, in this particular case, requires
something to prompt the user when all is not well, but that does not change
the logic.

Would you prefer

Do
Test for Success

If AllIsWell Then
Exit Do
Endif

MessageBox.Show("All is not well!")
Loop

Charles
 
Charles,

I started to tell you that this code you show is the one I was direct typing
when I saw those goto's we probalby both don't like.

However I saw that it was failing in this case (as well with the goto's),
when the user had not the possibility to change the evaluated variables
while there is no external process that does.

That was all

(How can I make this clear, will I sent you a sample program?)

:-)

Cor
 
Cor
(How can I make this clear, will I sent you a sample program?)

I don't think that will be necessary ;-)

I know what you are getting at, but I am still only trying to illustrate the
logical construct. The operations that the user includes within that
construct are a detail of their specific problem. The logic remains good.

In the OP's scenario, TestForSuccess translates to 'Get user input and
validate'.

I think that we do actually understand each other :-)

Charles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top