473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

extract IP address

hi
i want to extract ip address. like we have ip address 127.0.0.1
i want to extract ip address in 4 different variable like ip1=127 ip2=0,ip3=0 ip4=1

i have get ip address on label. like

Label1.Text = Request.UserHostAddress
how can i extract ip
pls help me
Sep 1 '07 #1
5 1881
debasisdas
8,127 Expert 4TB
Try to find out the position of . in the IP address using corresponding substring, instring and length functions of the language.
Sep 1 '07 #2
in C# you may done it through the following code

string sIPAddress=label2.Text;

string[] sExtractIPAddress=sIPAddress.Split('.');

string IP1=sExtractIPAddress[0];
string IP2=sExtractIPAddress[1];
string IP3=sExtractIPAddress[2];
string IP4=sExtractIPAddress[3];
Sep 1 '07 #3
SammyB
807 Expert 512MB
Looks the same in VB:
Expand|Select|Wrap|Line Numbers
  1. Dim s As String = Request.UserHostAddress
  2. Dim sExtractIPAddress As String() = s.Split(".".ToCharArray)
  3. Dim IP1 As String = sExtractIPAddress(0)
  4. Dim IP2 As String = sExtractIPAddress(1)
  5. Dim IP3 As String = sExtractIPAddress(2)
  6. Dim IP4 As String = sExtractIPAddress(3)
  7.  
Sep 1 '07 #4
thank you buddy for helping

Looks the same in VB:
Expand|Select|Wrap|Line Numbers
  1. Dim s As String = Request.UserHostAddress
  2. Dim sExtractIPAddress As String() = s.Split(".".ToCharArray)
  3. Dim IP1 As String = sExtractIPAddress(0)
  4. Dim IP2 As String = sExtractIPAddress(1)
  5. Dim IP3 As String = sExtractIPAddress(2)
  6. Dim IP4 As String = sExtractIPAddress(3)
  7.  
Sep 26 '07 #5
Plater
7,872 Expert 4TB
Actually the IPAddress class has a property that returns a byte[4]. Each of the 4 bytes represents one of the set of numbers in the address.
Sep 26 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: David Chang | last post by:
I am trying to do some analysis on customer's locality, so I'd like to extract numeric part from address. Here is how the table looks like Table Member first_name last_name address1 ...
2
by: MLH | last post by:
I routinely save failure notices from mail servers bouncing mail back to me that I sent with invalid address. I would like to write an access procedure in my contacts database that would open the...
2
by: tthomas | last post by:
Greetings, I am using CDO.Message to send email messages from my application. I now need to send email to existing distribution lists in our Global Address List. However, our exchange server...
8
by: Fabian Braennstroem | last post by:
Hi, I would like to remove certain lines from a log files. I had some sed/awk scripts for this, but now, I want to use python with its re module for this task. Actually, I have two different...
4
by: Farooqui | last post by:
Hi, I need help in writing a VB6 program to read 1000 word documents and extract my required information into a .dbf file. All word documents are having different information in a tabular form...
4
by: Alexander Vasilevsky | last post by:
How to extract email address from the letter in Outlook Express? http://www.alvas.net - Audio tools for C# and VB.Net developers
0
by: Alexander Vasilevsky | last post by:
How to extract email address from the address book in Outlook Express? http://www.alvas.net - Audio tools for C# and VB.Net developers
2
by: Alexander Vasilevsky | last post by:
I need extract email address from the address book in Outlook Express also. http://www.alvas.net - Audio tools for C# and VB.Net developers
2
by: hutch75 | last post by:
Hi All - chasing down a means to initiate a traceroute, record results, and extract IP addresses in an (array?) Here's what I'm thinking about so far, wonder if anyone's been down this road before...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.