|
-
Jun 5th, 2008, 05:24 AM
#1
Thread Starter
Lively Member
Setting IP Address using VB
can someone help me on how to set IP address using VB thanks
-
Jun 5th, 2008, 05:53 AM
#2
Hyperactive Member
Re: Setting IP Address using VB
-
Jun 5th, 2008, 05:55 AM
#3
Thread Starter
Lively Member
Re: Setting IP Address using VB
set IP address of my computer...
-
Jun 5th, 2008, 06:09 AM
#4
Hyperactive Member
Re: Setting IP Address using VB
You could change the LAN address using some API's probably. What exactly do you want to achieve as the end result?
_Pulled this code from google
Code:
Dim objWMIService, colNetAdapters, objNetAdapter
Dim strIPAddress, strSubnetMask, strGateway, strGatewaymetric
Dim errEnable, errGateways
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration " & "where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.1")
strGatewaymetric = Array(1)
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
Next
Edit: Seems to work. Does however break DNS server, work with it and see what you can get maybe
Last edited by Teseng; Jun 5th, 2008 at 06:19 AM.
-
Jun 5th, 2008, 09:53 AM
#5
Re: Setting IP Address using VB
If you programmatically change the IP address of your computer, isn't that going to mess up connections for you? Do you have a static IP, or are you using DHCP?
-
Jun 5th, 2008, 12:10 PM
#6
Re: Setting IP Address using VB
Probably not as its probably the local ip of the workstation and not the router.
You can also shellexecute the cmd.exe and pass the ipconfig /release amd then another one with ipconfig / renew but this wont let you specify the ip address.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 5th, 2008, 01:17 PM
#7
Fanatic Member
Re: Setting IP Address using VB
or you could just use shell and "netsh interface ip set address" ......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|