473,713 Members | 3,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stripping IP Address out of text file?

Hello, after learning that I was taking a class in VB.NET, I have been
drafted to solve all my companies VB/scripting problems - hey, I should know
everything; I've already taken 6 classes ;) I should have been quiet about
it, but then I would never be reimbursed. Oh well.

I have been asked to write a program to ping a NetBIOS name, get the IP, and
compare the 3rd octet to a list to get the computer's location. So far, I
can ping the IP, save the output to a text file, and open the file, but I am
having trouble stripping out the IP address. My code is as follows:

Private Sub ConvertButton_C lick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles ConvertButton.C lick

' Click a button, it takes the value of NetBiosBox and pings it, then

' saves the output to c:\vb\test2.txt

Dim RedirectFile As Object
RedirectFile = "c:\vb\test2.tx t"
Shell(Environ$( "comspec") & " /k ping " & Me.NetBiosBox.T ext & " > """ &
RedirectFile & """", AppWinStyle.Hid e)

' Here is where I open the file - but how do I get the data I need? All
samples I have assume fixed file sizes, etc.

FileOpen(1, "c:\vb\test2.tx t", OpenMode.Binary , OpenAccess.Defa ult,
OpenShare.Share d)

FileClose(1) ' Close file.

I can do comparisons, I'm pretty sure the docs I have for opening files are
thorough, and I feel I'm on the right track. Any help with the stripping out
of the IP would be appreciated. Thanks! If this is the wrong place for
questions like this - let me know where.

Jul 21 '05 #1
2 2313
Well, since no one answered, here is what I came up with for future
frustrated student reference. Wasn't as hard as I thought it was - just used
rudimentary info on Sequential files and a crash course in string
manipulation.

Private Sub OpenFileButton_ Click(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles OpenFileButton. Click

Dim strline as String
Dim stripOutput As String
Dim objStreamReader As System.IO.Strea mReader
' strIP(intX) will be an array we create from files read
Dim intX As Integer
Dim intY As Integer
Dim strZ As String
If System.IO.File. Exists("c:\wind ows\temp\test.t xt") Then
objStreamReader =
System.IO.File. OpenText("c:\wi ndows\temp\test .txt")
'TestOutputLabe l.Text = objStreamReader .ReadLine()
Do Until objStreamReader .Peek = -1
strline = objStreamReader .ReadLine()
intX = intX + 1
If intX = 7 Then
stripOutput = strline
stripOutput = stripOutput.Rep lace("Reply from ", "")
stripOutput = stripOutput.Tri mEnd(":")
intY = stripOutput.Ind exOf(":")
strZ = stripOutput.Sub string(intY)
stripOutput = stripOutput.Rep lace(strZ, "")
End If
'MessageBox.Sho w(strline, "Line", _
'MessageBoxButt ons.OK, MessageBoxIcon. Information)
Loop
objStreamReader .Close()
Me.TestOutputLa bel.Text = stripOutput

Else
MessageBox.Show ("The output file has not been created yet.",
"Sorry", _
MessageBoxButto ns.OK, MessageBoxIcon. Warning)
End If
Jul 21 '05 #2
Good Boy Patrick :-)
Thanks for not being yet another parasite using the newsgroups
to suck off the tit.
--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REM OVETHISTEXTmetr omilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Patrick" <pa*****@hello. com> wrote in message
news:OL******** ******@TK2MSFTN GP15.phx.gbl...
Well, since no one answered, here is what I came up with for future
frustrated student reference. Wasn't as hard as I thought it was - just used rudimentary info on Sequential files and a crash course in string
manipulation.

Private Sub OpenFileButton_ Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles OpenFileButton. Click

Dim strline as String
Dim stripOutput As String
Dim objStreamReader As System.IO.Strea mReader
' strIP(intX) will be an array we create from files read
Dim intX As Integer
Dim intY As Integer
Dim strZ As String
If System.IO.File. Exists("c:\wind ows\temp\test.t xt") Then
objStreamReader =
System.IO.File. OpenText("c:\wi ndows\temp\test .txt")
'TestOutputLabe l.Text = objStreamReader .ReadLine()
Do Until objStreamReader .Peek = -1
strline = objStreamReader .ReadLine()
intX = intX + 1
If intX = 7 Then
stripOutput = strline
stripOutput = stripOutput.Rep lace("Reply from ", "")
stripOutput = stripOutput.Tri mEnd(":")
intY = stripOutput.Ind exOf(":")
strZ = stripOutput.Sub string(intY)
stripOutput = stripOutput.Rep lace(strZ, "")
End If
'MessageBox.Sho w(strline, "Line", _
'MessageBoxButt ons.OK, MessageBoxIcon. Information)
Loop
objStreamReader .Close()
Me.TestOutputLa bel.Text = stripOutput

Else
MessageBox.Show ("The output file has not been created yet.",
"Sorry", _
MessageBoxButto ns.OK, MessageBoxIcon. Warning)
End If

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2492
by: Andy Jefferies | last post by:
I'm having problems stripping out the whitespace at the beginning of a particular element. In the XML snippet I've highlighted tabs and returns as ^I and ^M respectively: <para> ^I ^I ^I^M Some text with occasional highlighting. Some text with occasional^M highlighting. Some text with occasional <high>highlighting</high>.^M Some text with occasional highlighting. Some <high>text</high> with^M occasional highlighting.</para>^M
3
10695
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two fields: BuildName and RoadName. Both have the following properties: size 50, not indexed, not required, allowed zero length. Some records have BuildName, RoadName as null, some have content. No content is 50 chr long. When i run a Len(BuildName)...
258
8647
by: Terry Andersen | last post by:
If I have: struct one_{ unsigned int one_1; unsigned short one_2; unsigned short one_3; }; struct two_{ unsigned int two_1;
16
4331
by: John Smith | last post by:
Hi all Why doesn't this seem to work? void stripnl(char *sz) { char *nl; nl = strchr(sz, '\n'); if (nl) {
4
6670
by: Lu | last post by:
Hi, i am currently working on ASP.Net v1.0 and is encountering the following problem. In javascript, I'm passing in: "somepage.aspx?QSParameter=<RowID>Chèques</RowID>" as part of the query string. However, in the code behind when I tried to get the query string value by calling Request.QueryString("QSParameter"), the value I got is: "<RowID>Chques</RowID>". The special character "è" has been stripped out. The web.config file is...
2
286
by: Patrick | last post by:
Hello, after learning that I was taking a class in VB.NET, I have been drafted to solve all my companies VB/scripting problems - hey, I should know everything; I've already taken 6 classes ;) I should have been quiet about it, but then I would never be reimbursed. Oh well. I have been asked to write a program to ping a NetBIOS name, get the IP, and compare the 3rd octet to a list to get the computer's location. So far, I can ping the IP,...
4
4168
by: Spondishy | last post by:
Hi, I'm looking for help with a regular expression and c#. I want to remove all tags from a piece of html except the following. <a> <b> <h1> <h2>
1
1473
by: vunet.us | last post by:
I want to strip email from the text. Some of my users may send me a string: str = "This is email 1: me@me.com and here is email 2: <a href="mailto:me@me.com">me@me.com</a>" How do I parse the string to get email address only? I know I may use instr() to determine if email address exists, but please, give me a hint on how to handle it next.
7
1384
by: Benway | last post by:
Hey all, I have a file name like Eng-Cat-01-01-01.txt. I need to do a loop that starts stripping the letters from the front of this file name (which I'll store as a variable) until it reaches the "Cat" part. So I would have a variable "Cat-01-01-01.txt" that I can use to build up another string. Trouble is, I'm lost. Can't figure out how to do this in VB.net. Could anyone point me in the right direction?
0
8701
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9168
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9009
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7942
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4462
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.