This code actually "toggles" the connection, by retrieving it's current state, and then setting the opposite state..... but, in vb6 you'll need to add a reference to "Microsoft Shell Controls and Automation" before it will work for you, plus, you may need to change some variables to fit the name of your connection....

Dim objCP, objEnable, objDisable, colNetwork
Dim clsConn, clsLANConn, clsVerb
Dim strNetConn, strConn, strEnable, strDisable
Dim bEnabled, bDisabled

strNetConn = "Network Connections"
strConn = "Local Area Connection"

strEnable = "En&able"
strDisable = "Disa&ble"

Set objshell = CreateObject("Shell.Application")

If objshell Is Nothing Then
    MsgBox "Fooey"
    Exit Sub
End If


Set objCP = objshell.NameSpace(3) 'Control Panel

Set colNetwork = Nothing
For Each clsConn In objCP.Items
    If clsConn.Name = strNetConn Then
        Set colNetwork = clsConn.GetFolder
        Exit For
    End If
Next

If colNetwork Is Nothing Then
    MsgBox "Network folder not found"
    Exit Sub
End If

Set clsLANConn = Nothing
For Each clsConn In colNetwork.Items
    If InStr(LCase(clsConn.Name), LCase(strConn)) Then
        Set clsLANConn = clsConn
        Exit For
    End If
Next

If clsLANConn Is Nothing Then
    MsgBox "Network Connection not found"
    Exit Sub
End If

bEnabled = True
Set objEnable = Nothing
Set objDisable = Nothing

For Each clsVerb In clsLANConn.Verbs
    If clsVerb.Name = strEnable Then
        Set objEnable = clsVerb
        bEnabled = False
    End If
    If clsVerb.Name = strDisable Then
        Set objDisable = clsVerb
    End If
Next

If bEnabled Then
    objDisable.DoIt
Else
    objEnable.DoIt
End If

@rrajm, you need to open your OWN thread, we will then answer from there. This is a VERY old post(2006), nobody will give you help from here. Click HERE to open a new thread.:)

This article has been dead for over six months. Start a new discussion instead.