GoTo command in VB
Results 1 to 5 of 5

Thread: GoTo command in VB

  1. #1
    Senior Member
    Join Date
    Apr 2002
    Posts
    105

    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

  2. #2
    The Iceman Cometh
    Join Date
    Aug 2001
    Posts
    1,210
    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

  3. #3
    Banned
    Join Date
    Apr 2002
    Posts
    69
    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

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    105
    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

  5. #5
    The Iceman Cometh
    Join Date
    Aug 2001
    Posts
    1,210
    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
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides