Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GoTo Not Supported...What Do I Use??

Status
Not open for further replies.

hodgesp

Programmer
Apr 21, 2004
32
US
I have a user input page that constructs a SQL statement and sends it to a Crystal Report Viewer.

The problem is that if a user selects a record by its main key field "Track Number" no other criteria need be selected, and I would like to go ahead and send the request to the report without any further processing.

In my old VBA version of the program I just used a GoTo statement and jumped to the report output section.

Code:
GoTo Report   .....
.....
[i]skipped code[/i]
.....

Report:
[i]code to be executed[/i]

I have been looking in the help but as yet have not forund a successfull way to do what I want. I did try enclosing the code in a Function and a Sub but neither option didn't seem to work.

Anyone have any suggestions? I would very much apprciate.



 
are you sure? this is a console app that works for me
Code:
Imports System
Class TestGoto
        Public Shared Sub Main(ByVal args As String())
		Dim _input As String
		Console.Write("Enter string: ")
		_input = Console.ReadLine
		While Not (_input.Equals("end"))
			TryGoto(_input)
			_input = Console.ReadLine
		End While
	End Sub

	Public Shared Sub TryGoto(ByVal _input As String)
		If Not _input.Equals("goto") Then
			Goto label_end
		Else
			Goto label_to
		End If
		label_to:
		Console.WriteLine("goto ")
		label_end:
		Console.Write("Enter string: ")
	End Sub
End Class
Marty
 
Not to be a troll or anything, but maybe this is a good time to wean yourself off Goto?

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
OMG!

I didn't know that people still used goto's!

That's awesome! Well, not really...

It's kinda like playing "PONG!" with a quad 2.4GHz Zeon processor machine with 4 gigs of RAM and a 256MB multi-head video card.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Sorry... In answer to your question (hodgesp)... Would a simple "if" statement not do the trick for you?

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
if strTrackNumber = "" then
'skipped code
end if

'rest of code
 
I didn't know people would freak out like this to a simple question.

I am a newbe to ASP, trying to teach myself, and I was trying to convert an old MS-Access application that has a SQL back-end and a MS-Access front end to web based. I was trying to follow the same logic. Maybe it isn't what you would have done but I was willing to try it.

I went ahead a used a if statement. Happy Now!?
 
Hey hodgesp,

Its just that GOTO is seen as bad programming practice. If you had GOTOs all over the place (like in the days of BASIC code), it would be a real headache to debug.

Keith
 
Yes, this of course is true. By most standards it is bad programming practice but only because it was over-used, not because the construct itself was inefficient. That is why the term "Spaghetti Code" was coined. However, in moderation, I still believe that it can be used. It was the simplest way to go from the top of a massive mountain of code to the bottom, so even though it may have been old hat, my goal was to skip over a bunch of code that in a particular case was unnecessary and move on. It just seemed to be the simplest way. However, The If statement will work. [colorface]

Thank you for your assistance.
 
Sorry to jump on you like that, hodgesp, it's just that I've seen a lot of really bad code lately (some of it written by myself around 3 years ago), and seeing someone using a Goto just set me off.

Sorry.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top