Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Disable Or Enable A Hardware

hi there,

is it any method to use VB6 to disable a hardware and after that enable it?


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Enable/disable Hardware
hello, i have a question
is it possible to enable/disable a network adapter via programming?
10q for your time.

Hardware Enable/Disable
I need to find a way to enable and disable a network card just like you can do in Device Manager by right clicking on th item. I am looking at WMI. If anyone has any ideas please let me know. Thanks

Disable Hardware Button
Hi,anybody know how to disable all hardwarebutton when my program run? using embedded visual basic? Thanks a million

LAN Enable/disable

I am looking for the programming code equivalent of disabling or enabling the LAN connection on my PC. I have created a routine that I want to be able to share with my fellow workers, but during a portion of the routine I want the connection to the LAN disabled and as I wrap up the routine I want to restore the LAN to normal operation. Thanks in advance for your help.


Disable And Enable Help.
Can someone please help! I have a playlist application that I am writing (for college) and I need to enable or disable some buttons depending on the state of the listbox. I have one listbox called playlist and six buttons - add, remove, up, down, all and none.

The add button is always enabled and can be ignored here. The other rules are as follows:

If listbox contains no items all buttons are disabled.
If listbox contains items with none selected then all are disable except all button.
If all the listboxes items are selected then remove and none are enabled the rest are disabled.
If only one of the listbox items are selected the all buttons are enabled unless the top item is selected (up disabled) or the bottom item is a selected (down disabled).
If more than item is selected but not all the up and down are disabled the rest are enabled.

I have posted the code I am using currently below. It almost completely works however there are three problems (I've spotted so far).

1. The code only starts when a selection is changed. How can I make it run when a new item is added to the list also.
2. If I popluate the list and then delete all entries the all button should disable but it doesn't it stays enabled.
3. If I select all entries in one go and then remove them all together I get an error pointing to the If PlayList.GetSelected(x) = True line.

The code I use for the remove button is

Private Sub RemoveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveButton.Click
Do While PlayList.SelectedIndex <> -1
End Sub
This is my rules code

Private Sub PlayList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlayList.SelectedIndexChanged
If PlayList.Items.Count = 0 Then
RemoveButton.Enabled = False
UpButton.Enabled = False
DownButton.Enabled = False
AllButton.Enabled = False
NoneButton.Enabled = False
ElseIf PlayList.Items.Count > 0 And PlayList.SelectedIndex = -1 Then
RemoveButton.Enabled = False
UpButton.Enabled = False
DownButton.Enabled = False
AllButton.Enabled = True
NoneButton.Enabled = False
If CheckAllSelected(PlayList) Then
RemoveButton.Enabled = True
UpButton.Enabled = False
DownButton.Enabled = False
AllButton.Enabled = False
NoneButton.Enabled = True
ElseIf NumberSelected > 1 Then
RemoveButton.Enabled = True
UpButton.Enabled = False
DownButton.Enabled = False
AllButton.Enabled = True
NoneButton.Enabled = True
If PlayList.Items.Count = 1 Then
RemoveButton.Enabled = True
UpButton.Enabled = False
DownButton.Enabled = True
AllButton.Enabled = True
NoneButton.Enabled = True
Select Case PlayList.SelectedIndex
Case 0
RemoveButton.Enabled = True
UpButton.Enabled = False
DownButton.Enabled = True
AllButton.Enabled = True
NoneButton.Enabled = True
Case PlayList.Items.Count - 1
RemoveButton.Enabled = True
UpButton.Enabled = True
DownButton.Enabled = False
AllButton.Enabled = True
NoneButton.Enabled = True
Case Else
RemoveButton.Enabled = True
UpButton.Enabled = True
DownButton.Enabled = True
AllButton.Enabled = True
NoneButton.Enabled = True
End Select
End If
End If
End If
End Sub

Public Function CheckAllSelected(ByVal PlayList As ListBox)
Dim x As Integer
NumberSelected = 0
For x = 0 To PlayList.Items.Count - 1
If PlayList.GetSelected(x) = True Then
NumberSelected = NumberSelected + 1
Exit Function
End If
If NumberSelected = PlayList.Items.Count Then
CheckAllSelected = True
CheckAllSelected = False
End If
End Function
I am sorry if this is a bit too long. Any help will be greatly appreciated. I have alos attached all of my code to this posting.


Disable/Enable X
Hi, I'd like to know how to undo this:

Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

Private Sub Form_Load()
Dim sysmen As Long
sysmen = GetSystemMenu(Me.hWnd, 0)
Call DeleteMenu(sysmen, &HF060&, &H0&)
End Sub
The code disables the X button and removes the close menu item. My question is... how do I put it back?

Disable/enable Alt Only
Hello Gurus

How to disable/enable Alt button ONLY on WinXP?


Enable / Disable NIC
I want to know how to enable and disable the local area connection or the network card.

Basically, I am looking for an easy way to turn off my "always on" dsl without only clicking one button...I was thinking of having an app sit in the task tray that I can click to turn the connection on and off.

Any ideas are appreciated. And no, I don't want to turn the modem off since the connection is shared across more than one computer.

Enable/Disable NIC
Anyone have any code samples on how to enable/disable Network Adaptors?

i'd like to secure my program. only me can use the other forms and commands. everytime they will logged as guest the they cannot use the other commands. how can i do it?

Disable/Enable LAN
I am new to VBCity
I need a help. Hope you guys can help me. I am using Windows XP and using LAN (Not wireless) we can disable/enable lan by right click on Network Places ---> Properties and right click to Local Area Network and click on Disable/Enable. I want to do this through Visual Basic 6. Please give the code of it.


Edited by - jonybhi on 1/6/2006 10:54:36 PM

Enable / Disable LAN Connections
Hi guys

someone could help me how to enable/disable a local area connection using some code or an api in VB?

Thank you

Tab Strip - Enable/disable
Hello there!

Im doing a project for college in visual basic 6.0. But im having trouble with the tab strip that can be found under "components/Microsoft Tabbed Dialog control 6.0" But the thing is i have a tab that i want to be disabled until the program executes a command. When i have tryed to do this the whole tab strip gets disabled and i only need the one...

can anyone give me a hand with what i would code?

- regards Tilston

Enable/disable Proxy. Anyone Know How?

I'm looking for a way to create a tiny small app with two buttons to enable and disable proxy settings. I want this app to be on the desktop when it's run so that the users always see these two buttons.
Like this?

Anyone know how to do this?

Enable/disable TextBox
Hi, I'm wondering how to enable a TextBox as soon as a letter, number or other character is typed in another TextBox.

TextBox1 = Enabled
TextBox2 = Disabled

How can I enable TextBox2 when something is typed in TextBox1 ?
And how to disable TextBox2 again when TextBox1 is cleared ?


Enable Or Disable IE Proxy
I am trying to figure out how to effectively change the IE Proxy Enable setting, and also make it take effect.

I have code similar to the following that correctly sets the registry value:

Registry.SetKeyValue HKEY_CURRENT_USER, _
"SoftwareMicrosoftWindowsCurrentVersionInternet Settings", "ProxyEnable", _
IIf(bolEnabled, "0", "1"), "Dword"
However, IE doesn't always recognize the change. As well, IE windows that are already open ignore any change of setting.

When you go into Internet Options, and enable/disable the proxy from there, I think it goes through some settings refresh procedure and then ALL browser windows will recognize the changed settings. This does not happen if I simply change the Registry key.

Does anyone know how I can make all the IE windows recognize the changed setting after I change it? I have searched PSC, Google, etc. and I have been unable to figure this out for a while now. Thanks

DHCP Enable/Disable
Would anyone know if there is a way to enable/disable DHCP in VB 6.0??? If so could you point me to the right direction. Thanks

Reason why : The reason why I would want to this for my laptop... My home network (LAN) is on DHCP and at work I use Static addressing. So to save mysef some time everyday I am writing a program to change the Enable/Disable DHCP and when DHCP is Disabled to assign my Static IP,Subnet,Gateway,DNS1,DNS2 and ESSID to my laptop. So far everything is going good(i think) on this (sense I am new to VB).

Enable/Disable Problems!
I have been trying to make it to where when:

check2.value = 1 = true then check1.enabled = false

and also

check2.value = 0 = true then check1.enabled = true

so i came up with this:

Private Sub Form_Activate()
If Check2.Value = 1 = True Then Check1.Enabled = False
If Check2.Value = 0 = True Then Check1.Enabled = True
End Sub

Which as I can tell is'nt right but I am not sure what to do, I have tryed many different things but nothing seems to work. Thanks ahead of time!

Enable/Disable An Index
I am trying to reset some tables in a database. When I tried to use Truncate ( Delete takes longer time and there is also transaction log issue which takes space on server), I realized that one of the tables has an Index, so naturally Truncate fails for that table.

So I wonder if there is a way to disable Indexes so I can Truncate such tables. Ofcourse I need to enable them after truncation.

BTW, The Database Server in question is MSDE.

Enable/disable Keyboard
I want to make a vb script which can enable or disable my keyboard.
which functions schould I use ?

Enable/disable Monitor
If i got a system with 2 monitors (e.g. the default monitor and a tv-out), how could i using code enable the 2nd monitor? Been googling all evening, but i can't find a proper API to enable this.


Enable Disable Frame VB6
Hi guys,
This is a shorty.
I have two opt buttons in array, two frames in an array.
if opt(0) is selected then only frame(0) should be enabled and vice versa. Somehow Iam not getting the code Can somebody post a snippet.

Enable/Disable Devices

Is there a way to enable/disable devices just like the Device Manager through code?? Either VB6 or VB.NET or API?


How To Disable And Enable A Lan Connection?
How To Disable and enable a Lan Connection?

Disable/Enable Keyboard
I know how to disable the keyboard and then be able to enable it again without reset?

Shell "rundll32.exe keyboard,disable", vbNormalFocus

i know that disables it but it wont enable it. Anyone know?

Disable And Enable Label
If anyone know, on how to disable and Enable a label on Data Report upon Datareport1.PrintReport ?

Form_Resize - Disable/enable
How can the resizing of a form be enable and disabled at run time?

Enable/Disable ScreenSaver...?
can anybody help me with an example of how to do that through code?

Disable And Enable Mouse
regarding to the subject, may i know how to use API to disable the mouse and enable it back.

Enable / Disable Autorun

Can anyone help me with a method to disable and enable the autorun of CD-Rom's via code?

I would also like to be able to check what
the user's current setting of Autorun is, and be able to restore it when exiting my prog.


Enable / Disable Autorun

Can anyone help me with a method to disable and enable the autorun of CD-Rom's via code?

I would also like to be able to check what
the user's current setting of Autorun is, and be able to restore it when exiting my prog.


Disable And Enable Button
Hi All,

I have a button with the code...

Private Sub Send_Click()
Send.Enabled = False
ActiveWorkbook.SendMail "MYEMAIL ADDRESS", _
End Sub

So, after one click, the button gets disabled and an e-mail is sent. What I would like to do is, if any of the following Cells, A1-A3 & C1 - C3 are changed, the button is enabled again. Any ideas?

How Can I Enable/disable Printer-fax In Vb?
Hope someone can help--
I'm trying to programmatically enable my fax device (as you would if you went to "printers and faxes" and did so), send my fax, then disable the device. I've got the code worked out for sending the fax, but don't want the device on all time--and it's got to be possible...isn't everything?

Thanks in advance!

Need More Help With Enable And Disable Internet!!
is there a way to enable and diable the internet connection of remote computers using visual basic ? I mean i can control to let or not to let the remote computer to have assess to the internet. Please help me??

Is It Possible To Enable Or Disable A Device?
I need to know if it is possible to dissable a device with VB code.

There are some unique circumstances in my workplace in which this could be very usefull.

The user can only run under one account so individual settings per account are out of the picture.

Thanks in advance for any suggestions!

Using Api To Enable/disable A Button
how can i use api to disable or enable a button. I would have thought i have to use some sort of send message command, passing in the handle of the window, but i am not sure and cant get it to work.

i want to be able to control my other applications, by using api.

Enable Disable Proxy
Hi aLL

how can I do to enable and disable IE proxy just in one clik button with
Visual Basic please.

thank you.

Disable/enable Lan Connection

I would like to enable/disable the LAN-connection to the network by code, but i don't find how to do it. Anybody knows the answer?


Enable/disable LAN Connections
someone could help me how to enable/disable a local area connection using some code or an api in VB?

Thank you

Enable/Disable DHCP In VB6
I am looking for a way to Enable/Disable DHCP in vb6? Also to grab the SSID of a wireless nic. Is this possiable in VB6???

Any help would be great!

Enable/disable Service
Hi all,

How do I go about enabling/disabling an existing Windows NT service using VB6 code.

Thank' in advance.


Enable/Disable LAN- Pls Help Its Urgent
Hi All,

 As we know we can enable or disable LAN connection by right clicking the icon on systray.
But i want to Enable/Disable LAN through VB.

I'm using Dial UP connection ,so when it goes down i've to jump on LAN by enabling it & when dial up starts working i want to jump back on tht by disabling the LAN.

Is it Possible. Please Help me on this .Its Urgent?


Edited by - kshipra on 12/21/2005 3:31:39 AM

Enable/disable Proxy Thru VBA

I am able to enable the proxy and feed my provided IP address and port no for the proxy.This works fine but when i try to disable it and go to the tools->Internet Options->connections->LAN settings i dont see it disabled.
Even rebooting the machine didnt help.
The the probelem is that i am able to enable and feed the value but am not able to disable the proxy thru my application.
I am using VB 6.0.
Here is the code :

Private Const HKEY_CURRENT_USER = &H80000001
Private Const REG_SZ = 1
Private Const REG_SZ1 = 0
Private Const REG_BINARY = 3
Private Const REG_DWORD = 4
Private Const ERROR_SUCCESS = 0&
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey _
As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal
Hkey As Long) As Long

'this function enables the proxy and the value i have hardcoded
Private Sub Command1_Click()
proxy = ""
Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")

Call savestring(HKEY_CURRENT_USER, "SoftwareMicrosoftWindowsCurrentVersionInternet Settings", "ProxyEnable", 1)
'Call savestring(HKEY_CURRENT_USER, "SoftwareMicrosoftWindowsCurrentVersionInternet Settings", "ProxyServer", proxy)
WshShell.RegWrite "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet SettingsProxyServer", "", "REG_SZ"
Form1.Label1.Visible = True
Form1.Label2.Visible = True
Form1.Label3.Caption = "The Proxy Is Enabled On This Machine"
'MsgBox ("Enabled")

End Sub

'this function disables the proxy (it has a problem i guess)
Private Sub Command2_Click()
Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")
Call savestring(HKEY_CURRENT_USER, "SoftwareMicrosoftWindowsCurrentVersionInternet Settings", "ProxyEnable", 0)
WshShell.RegWrite "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet SettingsProxyServer", "", "REG_SZ"
'MsgBox ("Disabled")
Form1.Label1.Visible = False
Form1.Label2.Visible = False
Form1.Label3.Caption = "The Proxy Is Disabled On This Machine"

End Sub

'just to exit
Private Sub Command3_Click()
End Sub

'the form load function
Private Sub Form_Load()
Form1.Label1.Visible = False
Form1.Label2.Visible = False
Form1.Label3.Caption = "Please Click To Enable Or Disable The Proxy"
End Sub

'this function is called from above to enable/disable proxy Setting
Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strdata As String)
    On Error Resume Next
    Dim keyhand As Long
    Dim r As Long
    r = RegCreateKey(Hkey, strPath, keyhand)
    r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, strdata, Len(strdata))
    r = RegCloseKey(keyhand)
End Sub



Enable/disable Menu
I have a menu on my MDI form. I created the menu using the Menu editor. Is there a way I can automatically disable this menu every time i choose ab item on the menu? or. is there a way i can disable the menu every time a child form is displayed and enable the menu again once the child form is close or unloaded?

Thanks in advance!!!!

Cookie Enable/Disable
Can anybody give solution regarding :
1. How to know the cookie,which I've send to the client is enabled or not.
2. How to know my IIS server is on or not from VB. Which API can be called .
If the IIS server is down How to start from the VB application.

I'll be greateful if any body can send the sample copy for the above problems.

About Popup Menu Enable And Disable
in my Poup menu code
If Entity_Fun <> "yes" Then
.Enabled = True
.Enabled = False
End If

i have a function called :
Public Function Entity_Fun() As String

So when the Popup menu code is check if it's enable or not, if should go to the function above and if it has something then it will give 'yes' if no then vise versa.

but now i want to make my popup menu code as
If Entity_Fun & "_" & dimension(count) <> "yes" Then

dimension is a variable that stores a string called "Entity"
so if i change the function into
Public Function Entity_Fun_Entity() As String
it suppose to go to this function above right ??
it's logic term
but in real world, it doesn't go to that fucntion and give me erros
"type mismatch' or "varible not declare "

can you help me ??

Disable/Enable Menubar Items
I would like to have certain items from a custom menu disabled/enabled when the active Workbook has a filename in the format '#####$ Overview.xls'

Is there an 'On Open File' or 'On Open Menu' event that I can use for this?


Enable And Disable Of A Command Button
I need to disable a command button when there is no text in a text field/area, but as soon as a character or string has been entered, the button must be enabled again.


Disable/enable Macros Message
Hello anybody

Maybe you can help me.

I've created an Excel file that starts a macro once opened.
But I always receive a message asking me if I want to disable or enable the macros when the file opens.

Is there any way to get rid of this message? Saying always activate the macros...

Thanks a lot for replying.

Copyright © 2005-08, All rights reserved