ciao a tutti, premetto di essere una new entry... sia nel forum che nell'ambiente di programmazione VB6!
Ho googlato un po' e girato il forum, ho trovato vari codici per fare quello che voglio e una volta trovato il codice che facesse il suo dovere nel modo migliore, ho voluto modificarlo!

Premessa: il programmino .exe che voglio creare deve girare solo su window XP, non ho pretese per altri sistemi e io utente in quanto utente Xp l'ho già testo. (lavoro con VB 6.o)

Il programma deve avere questo fine: con un comando deve abilitarmi la scheda di rete e con un altro deve disattivarmela.

Il problema è che il codice che ho trovato io... (nel quale ci capisco si, ...ma a grandi linee...) disattiva e riattiva la scheda a seconda dello stato in cui si trovi, tutto tramite l'esecuzione di un Command. Io NON voglio faccia questo... Voglio che se attivata la disattivi e basta, per il primo pulsante e per il secondo faccia il contrario... ma non tutte e due le alternative con un solo command. Spero di essere chiaro... bah

Sapreste postarmi un condice rielaborato da questo, che faccia quello che mi serve?


il codice è:



Private Sub Command1_Click()

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

strNetConn = "Connessioni di rete"
strConn = "Connessione alla rete locale (LAN)"

strEnable = "&Abilita"
strDisable = "&Disabilita"

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
End Sub


Grazie in aticipo, e spero di essere stato il più chiaro e semplice possibile sulla mia richiesta.