-
June 20th, 2002, 12:51 AM
#1
Senior Member
GoTo command in VB
does anyone know how to properly use the goto command in visual basic? im trying to make it go to a specific line in the code but i cant figure out how it works
and yes i know im a n00b!
--=::[ LeNc}{ ]::=-- stealing your time for pathetic web sites since 1998
-
June 20th, 2002, 12:55 AM
#2
Personally, I haven't used the goto command in VB, though I have used it in other languages. In my opinion, I would try to find another way to do it because using the goto command creates what my instructors have called "spaghetti code" where you're constantly jumping back and forth in the program source code when trying to debug it or even just understand it.
AJ
-
June 20th, 2002, 01:08 AM
#3
Banned
The goto command jumps to another section of code, mostly on errors, heres an example from the MSDN library:
Private Sub Command1_Click()
Dim source As String
Dim target As String
On Error GoTo err_handler
source = "c:\test.txt"
Open source For Output As #1
Write #1, "This is a test."
Close #1
target = "a:\test.txt"
If Dir(target) <> "" Then Kill target
FileCopy source, target
Exit Sub
err_handler:
If Err.Number = 70 Then
MsgBox "Permission denied. Please remove write-protection."
Resume
ElseIf Err.Number = 71 Then
MsgBox "Disk not ready. Please insert a disk."
Resume
End If
End Sub
-
June 20th, 2002, 01:13 AM
#4
Senior Member
thanx guys my school deleted the MSDN library off the class server and ive been messin with the code for ages uve been a real help
--=::[ LeNc}{ ]::=-- stealing your time for pathetic web sites since 1998
-
June 20th, 2002, 01:16 AM
#5
One tip, for later reference... most of the MSDN library is also available online at http://msdn.microsoft.com/library/default.asp
AJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|