Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting IP Address etc.

0 views
Skip to first unread message

Stephen Myers

unread,
Jun 28, 2001, 10:06:35 AM6/28/01
to
Hi,

I need to know how to set a static IP address using VB.
Also setting the Subnet Mask & Default Gateway aswell.

If it makes a difference, the Computer already has a static IP address which
needs changing, it is not using DHCP.

Many Thanks
Stephen


Alick

unread,
Jul 3, 2001, 3:44:40 AM7/3/01
to
Hi Stephen,

The only way I know of to change this is via WMI (Windows Management
Instrumentation). Here is a code segment to assign a static IP address to
your computer. If you are not using Windows 2000 or Windows Millennium then
you will have to install WMI on the Computer.

Dim Adapter As Object
Dim ipaddr As Variant

Dim subnet As Variant
Dim gateway As Variant
Dim DNS As Variant
Dim RetVal As Integer

Set Adapter = GetObject("winmgmts:Win32_NetworkAdapterConfiguration=0")

ipaddr = Array("199.60.71.155")
subnet = Array("255.255.255.0")
gateway = Array("199.69.71.1")
DNS = Array("199.67.38.7")

'Set your adapter to a static IP address
RetVal = Adapter.EnableStatic(ipaddr, subnet)

'Set your gateway
Adapter.setgateways (gateway)

'Set your DNS
Adapter.SetDnsServerSearchOrder (DNS)

0 new messages