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

How To Find The IP-adress Of A Computer/find A String In A .txt File

How can I (by using code) find the IP adress of a pc? i have tried with WMI but i cant find it ... otherwise i have no ideas how to do it ... the only thing i can think of is pinging to it and then save that into a .txt file. but then i got the problem i cant find a way to find the ip adress ... i have tried to searach for the position of the words right before it("Antwoord van:") and behind it (": Bytes") but it doesnt seem to work out.

can anyone of you give me a solution / more ideas?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How Do I Find A File On My Computer...RESOLVED
How do I have my VB6 program find a file of a particular name on an unknown drive on my computer?

I want this process to be invisible to the user. In other words, I don't want the user to have to search for it.

Edited by - SchMan on 4/1/2004 11:44:01 PM

Find Path Of Specific File In Computer.
Can anybody please tell me how to write the macro that find the path file such as word.txt or notepad.exe in the computer?

Is There A Find Function To Find The Position Of A Character In A String?
I am using Microsoft Excel 2000.
I wanted to know if there is a way of easily finding the position of a character in a string.
My main problem is that I need to go thru a string and remove all characters that are not letters or numbers.

This is what i am doing so far: (i would be most grateful for any suggestions or help)

Dim yo As String
Sub kristy()

    Dim numberofcharts As Integer
    Dim name, name2, tempa As String
    numberofcharts = 200
    'loop thru each chart and select the title and use that as the file name
    For i = 1 To numberofcharts
        name = ActiveChart.ChartTitle.Text
        tempa = name
        name2 = StripOut(tempa)
        fname = ThisWorkbook.Path & "" & name2 & ".png"
        ActiveChart.Export Filename:=fname, FilterName:="PNG"
        name2 = ""
    Next i
End Sub

Public Function StripOut(from As String) As String
    Dim h, a, b, c, result As Integer
    Dim tempChar, temp, str1, str2, str3 As String
    StripOut = from
    str2 = "abcdefghijklmnopqrstuvwxyz"
    str3 = "1234567890"
    For h = 1 To Len(StripOut)
        temp = Mid$(StripOut, h, 1)
        a = InStr(str1, temp)
        b = InStr(str2, temp)
        c = InStr(str3, temp)
        If ((a = 0) And (b = 0) And (c = 0)) Then
            'if the character is bad then delete it
            StripOut = Replace(StripOut, temp, "")
            'put something here so that it looks for the previous thing in the string and then increments it by one
        End If
    Next h
End Function

Thanks for any suggestions!!

Edited by - kristy2710 on 6/3/2004 1:41:02 PM

Find A String In A Text File
How do i search through a text file and find a string, then select a string that follows the search criteria and copy it into a variable?

eg. How do i find "From:" and copy just "" in the entire string that would read something like:



From: Person <>

they are on their own line so i suppose you could find the end of the string by looking for vbCrLf

Can you help?

Find String In File And Replace

I'm putting together a program that will be adding strings to a html page.

I've set the html page up with flags like %title% etc for the VB to find and replace with its stored variable.

I've had a look round the forums but havent been able to find anything that is of any use.

InStr looked promising but I'm not sure how to adapt it for use with a file.

Any hints would be appreciated.



Find String In Text File....
How to find a string in text file in a fixed posistion....
Attached is my file.
I want to find in all line of text file the string, for example, with MY_VAR="INDEX-9476330-H7469-CON-4546-29/06/2005", but find only in position 126 to 165...
After is found the string appear msgbox("found") in posistion line nr. xxxxx
You know: the var have always the the same lenght

[Solved] Go Through File, And Find String
How would I go about writing code to accomplish...

I have a variable txtVar1, I want to add this into a file, between

<!-- VB Generated -->

[/code]<!-- End VB Generated -->[/code]

How would I go about writing the code that will go find these 2 strings, or find the last bit, and add the var above it.


Find A String In An Html File
Hi everyone... I am completely stuck on this and cannot find a solution that works anywhere.

I am looking for a way to open a locally saved html file, and get it to look for a particular string and then if it finds that string then do something else with it....

Does anyone know any code that will do this.



Find Macro Or Open Find &"find' In Excel Form
How can I make a macro or what is the code to open and use the "find" in excel using a form. I tried to record the macro opening the Edit then Find. Please fully explain if possible.

Thanks in advance.

Find And Replace A String In Text File
How can i Find And Replace aString In Text File?

Thanks in advance

Public Function ReplaceStringInFile(ByVal StrFileName As String, _
ByVal StrFind As String, ByVal strReplace As String) As String

Dim strTest As String

Open StrFileName For Binary As #1
strTest = Space(LOF(1))
Get #1, , strTest

strTest = Replace(strTest, StrFind, strReplace)
Put #1, , strTest
Close #1

ReplaceStringInFile = strTest

End Function

Find And Replace String In A Text File
Dear All,

I need to find and replace all chr(10) with "" in a big text file (with more than 150k rows inside), how to do this with VB6?

many thanks in advance


Find String In File, Print Number?
Hello everyone;

I'm sorry if i'm in the wrong area for this but this may be quite simple to all of you...

I have a batch file which checks to see if specified servers are online, and prints a "success" or a "failure" to the screen adn to a text file.

What I want to do is, at the end of the batch file, search the file that was created for a string such as "Reply from" and print just the number so that I can type a sentence in like...

Finished processing, there are (number of replies found) out of (number of total servers) online right now.

I'm sorry, I have been searching for hours and I am completely lost...


How To Find And Replace A Specific String In A Text File

I have an app which read a CSV format text file an example is:


Now when I read this file using the statement

VB Code:
Open c:Test.txt for Input as #fNum Do Until EOF(fNum)Input, #FNum, var1,var2,var3,var4loopClose #fNum

Now I want to check the value of var4 if it's current date then var3's value should be changed. Any ideas on this?

Thanks in advance

Loading A Binary File Into A String And Find / Replace

I'm trying to take a binary file (a Flash movie .swf file), load it into a String variable in VB, then search for occurrences of the string 'word1' and change it to 'Price'. Then, I want to write the data back to disk as a new file. Sounds simple, but I'm stumped for how to do it!

Hope someone can help - thanks!


Find String In Text File And Compare What User Types
hallo, ok so what i want to do i want to put numbers into a text file alot of em in this order


like a different number each line and i want visual basic to find a certain string while the user types the 3 digit code an display text like

if area1.text = "719" then
label1.caption = "Colorado"
Else ?????????????????? like go threw the whole list finding what the user types and display info about it ty for your help

Loop Through Text File -Find String - Delete Line
Hey all
Im having some trouble with a VB script and was told this is the place to go for help.

What I have is an IIS log that I would like to alter for an easier report for my Sup's to view.
It looks like this below


2005-03-21 00:00:38 - 80 GET /robohelp/SHPSMATE/SHPSMATE+v3/news.asp - 304 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1)

The problem is this page is set to refresh once a minute and is used by about 1000 people so my log is just overrun with it. What I would like to do is run a VB script that will open the file(its been converted to a text file) loop through it searching for a string that contains "news.asp" regardless of the time or IP connecting and then delete that entire string out of the file

Problem is Im a little lost Ive been reading up and found that InStr option will be little help and everyone seems to be pointing me to a VB option

does anyone have a good idea on how I could start this out
Thanks a bunch in advance for any help

Find Out The Computer Name
Hi there,

I'm writing a program that will capture the printers installed on the computer where the program is running. I know how to get the printer names, but how can I find out the computer name using VB code?


P.S. btw, the system is part of a domain and the OS is Win2k, XP, or 2003 server.

How Do I Find The Computer Name?
Hello again!

How do I find out what a computer's name is? This is for the machine that the application is running on.


How To Find A Computer On Or Off
Guyz, iam using access as backend which is in another system, juz like client server application.While logging in ,i will check the user from the table in the server.If server is switched off,i want to give user friendly message, so i need to trap whether the server is on or off.I tried with isdestinationreachable,the sad part is that it will tell whether a system is found in network or not.It returns true if a system is found in network even when the system is off.What to do to find out whether that system is on or off?
Thanks in advance

Can I Find The Name Of A Computer
Is there a way to find out what the name of a computer is.

Find A File, Find Text Within A File, Then Change It
Find a file, find text within a file, then change it, how would I go about doing that

Find IP From Computer Name On Network
I am going to make a chat program, but I need to know the IP's of the computers. I know all the computer names, but how do I get their IP's?
I'm guessing I have to ping them but how would I go about doing that?

Find Computer Name And Either End Or Run Program

I am working on a script that will add 2 domain user groups to the administrator local group. I have the script working and I want to use this as a startup script. I have that working also, the problem is this:

I want to omit 3 different computers on my network from running this script, they are all servers. I would rather the script be able to look up the computer name, and if it's 1 of the 3 just end, but if not then it should run. I have it telling me the computer name, but when it gets the the "Wscript.echo NGIT" it stops all together. Could someone please tell me what is wrong with this code and help me out. Thanks. Here is the code.

strComputer = "."
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
strserver = "Server"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
NGIT = "0"
Hardware = "0"

Dim oWshShell 'Windows Script Host Shell object
Dim sCurrentName 'holds computername environment variable
Dim oWshEnvironment 'Windows Script Host environment object

Set oWshShell = CreateObject("WScript.Shell")
Set oWshEnvironment = oWshShell.Environment("Process")

sCurrentName = oWshEnvironment("COMPUTERNAME")
wscript.echo sCurrentName
if sCurrentName = "TEST" then
Wscript.echo "Names Match"
wscript.echo NGIT
Wscript.Echo "Not a Match"
Hardware = Hardware + 1
Wscript.echo Hardware

For Each objUser in objGroup.members
if = "NGIT Developers" then


end if

If NGIT = 0 then
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strserver & "/ngit developers,group")

end if

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")

For Each objUser in objGroup.members
if = "Hardware Support" then
Hardware = Hardware + 1


end if
If Hardware = 0 then
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strserver & "/Hardware Support,group")

end if

Vb Code To Find A Computer On Or Off
Guyz, iam using access as backend which is in another system, juz like client server application.While logging in ,i will check the user from the table in the server.If server is switched off,i want to give user friendly message, so i need to trap whether the server is on or off.I tried with isdestinationreachable,the sad part is that it will tell whether a system is found in network or not.It returns true if a system is found in network even when the system is off.What to do to find out whether that system is on or off?
Thanks in advance

Find Ports On A Computer
Have posted this before

I need to know / if possible

How mant PCI, AGP and PCI-e ports a computer has

Cheers ILMV

Find Computer Speed
is it possible to find the computer speed using vb ?

also i need to find the ram of the machine.

Find WinWord.exe On Computer
i am making an add-in program for MS WORD and i need to find the direct path of MS WORD so that i can use it to launch it from my vb program.

i have used the Dir$ method:

if len(dir$("winword.exe")) <> 0 then
msgbox "It exists"
msgbox "It doesn't exists"
end if

this tells me if the file exists or not, but i still need the path name of the file, (i.e. "C:program filesmicrosoft officeofficewinword.exe")

how can this be done.

Find All Drives On A Computer
How do you look up what drives are available on a user's computer? I'm trying to find out what drive letters are available so I can search for files.


Suggestions On Best Method To Find Computer Name
Situation - have a VB client app. Runs on a WAN - many computers around town - lots of buildings.

SQL Server 2000 backend.

We have an APPCONNECT table that stores a record for each time a person connects to the database - what client program they connected with (app.EXEName, app.Title, app.Major, app.Minor, app.Revision) and where they ran it from (app.Path).

In the STORED PROC we also store the SYSTEM_USER in this row (nice little DOMAINUSERNAME).

Along with all this we also have CLIENT TIME for connection and SERVER TIME for connection.

Question is - what are some ways I can find out WHERE THEY CONNECTED FROM. Is it easy to find out COMPUTER NAME - is IP ADDRESS better. I'm not even sure what method to use to get this information.

Any help would be greatly appreciated.


How Can I Find Out What Computer A User Is Logged Onto?
Our support techs use SMS to remotely control users desktops when the user has a problem. SMS lists all the computer names, not users. Most office people have no idea what thier computer name is and walking some of them through the process can be a nightmare.

I have been able to read all of the networked computers with no problem (image 1). I have also been able to get all of the users logged onto all available domains with no problem (image 2). What I would like to do it be able to type in a user name and find out what computer they are logged into and be able to type in a computer name and find out what domain user is logged onto that computer.

I can't find this anywhere! The only examples I have seen are for the NetUserGetInfo api which enumerates the users on a specific machine, but it gets all the SERVICE users - NOT the users that are logged onto the domain (image 3). I have searched high and low. Has anyone seen this or even know if it can be done? Thanks in advance guys and gals.

How Do I Find All Computer Names On A Network?
Hi all,
I want to know how to find all the computer names on the network, i saw a link to some code once, but can't remember where it was.

If anyone can help that would be great.

Thanks all in advance

Find The Drive In The Computer ? - For Experts
hi !

i want to know how i can defin to combo box to show me the list of all the drive that the user have in his computer .

E.g : if i have in my computer the drive : a,b,c,d,e i will see in the combobox a list with all the drive type .

10x .

How To Find OS Version Of Remote Computer?
Hi all,

Anyone know how to find OS version of remote computer via programming VB6, please help me

Thanks alot!


What Is The Code To Find Out Computer Identification Number
What is the code for getting computer identification number and getting it displayed in a textbox ?

Amit Bhaduri

LDAP Query To Find A Users Computer
I am doing this in Access, but its more VB than anything else so figured it would be beter to post here.

Hello folks,

Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the SAMAccountName to retrieve the last computer the users logged on to. But i am looking for a place where i can learn this information. I was hoping someone out there could point me in the right direction.

Below is my code which i have been working on. It can retrieve the samaccountname information perfectly. I just can't get the lastlogon to work nor can i find how to bridge the name with a computer on LDAP . Any help would be great


Function Get_User_Name_AD()
Dim adoCommand, adoConnection, strBase, strFilter, strAttributes

Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strCN, strLastLogin

' Setup ADO objects.

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

' Search entire Active Directory domain.

Set objRootDSE = GetObject("LDAP://RootDSE")

strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"

' Filter on user objects.

strFilter = "(&(objectCategory=person)(objectClass=user)(cn=Juan* ))"

'================================================= ==========
'"(&(objectCategory=person)(objectClass=user)(cn=Joe*) )"
'================================================= ==========

' Comma delimited list of attribute values to retrieve.
strAttributes = "sAMAccountName,cn,distinguishedName, mail, lastlogon"
'================================================= ==========
'SAMAccountName CN DistinguishedName
'mail company givenName sn
'ADsPath name sAMAccountName telephoneNumber

' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

' Run the query.
Set adoRecordset = adoCommand.Execute

' Enumerate the resulting recordset.
Do Until adoRecordset.EOF

' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value

strCN = adoRecordset.Fields("cn").Value

strLastLogin = adoRecordset.Fields("Lastlogon").Value

'Wscript.Echo "NT Name: " & strName & ", Common Name: " & strCN
Debug.Print "NT Name: " & strName & ", Common Name: " & strCN & "-" & strLastLogin
' Move to the next record in the recordset.

' Clean up.



End Function

After Computer Crash Program Cant Find Vba6.dll

My hard drive crashed a while back, the drive was cloned everything was saved, sort of except my email. When my friend set up my computer he did it under a different username spelling my name incorrectly 'deloris' so he made another 'dolores'.

All my files where there but they didn't recognize the new name 'dolores' and many I had to install again because they were missing files.

I have a program called style writer that works in microsoft word but when I try to use the program it can't find VBA6.dll, I tried reinstalling it and the came pop up comes up. If I can find one online (if possible) what folder would I put it in?

Any help would be appreciated


Find User Accounts On Computer? &lt;Resolved&gt;

I am looking for a way to get all the user accounts on a computer programmically.

I know this has to be out there some where..

Thanks in Advanced!


Dave Barr

Edited by - crazyoldman on 12/7/2006 1:24:05 PM

How To Find Out Whether An External Device Is Connected To The Computer
i have a dictaphone which i m attaching 2 my computer.How can i find out whether it has been attached or not?How will i b able 2 access the dictaphone through the computer?

Find The Repeating Files In The Entire Computer

i want to find a method to search for all files in the entire computer and listdown all the repeatin file names with the same size with their respective paths.

thankin you in advance...


Find Outgoing Smtp Relay For Local Computer
how to find mx outgoing smtp relay for local computer ?
usually it starts with

How To Find All The Files Of A Computer With An Specific Extension? *RESOLVED*
Hey guys! I have a code to find a specific file... Then I tryed to change it to find all the files with a specific extention, like ".htm"

But it seens not working... I already tryed "*.htm" and chr$(42) & ".htm"...

Here is my piece of code...

For driveexist = 0 To Drive1.ListCount
driveletter = Left$(Drive1.List(driveexist), 2)
file = FindFile(driveletter & "", "open.html") 'I am trying here to make it search from *.extension of the file
If file <> "" Then
Exit For
End If

Anybody have ideas to solve it? =-)

thanks guys!


I Found A Solution To Find Out If The Computer Is Connected To The Internet
Catchy topic uh? Well I wanted to share my solution so people can tell me if there's anything wrong with it.

There is many solutions to know if the current computer is connected to the internet but none does the job 'correctly'. Here is some info I found on the subject:

1. User Registry: This is the easiest way to check connection. Checking registry value of SystemCurrentControlSetServicesRemoteAccess from HKEY_LOCAL_MACHINE. Using RegOpenKey function from advapi32.dll. Unfortunately, checking is ONLY for MODEM connection. If you are connecting to Internet via Local Area Network (LAN), this method return False even if you are connected

2. Using InternetGetConnectedStateEx: This method use InternetGetConnectedStateEx function from wininet.dll. It works fine, but there is one problem. If your computer is in Local Area Network but you are connecting to Internet via modem, this method always returns True, in case you are connecting to Internet or not

3. Using direct ping to This method use direct ping to some Internet address (URL) and checking for connection errors. Now it use http:/ It's not so quickly, as previous two, but this method is the most reliable

Unfortunately, the third solution, which seemed to be the best one, takes 40 seconds for pinging when not connected. This is too long.

My solution: I am using the winsock control to connect to an ftp (say and if the winsock STATE is not "connected" within the next 4-5 seconds, the computer is not connected to the internet.

Please feel free to add your comment.

Find Computer Name - Or Listing Of All Environment Function Display
"Environ" function in VB returns operating system environment variable.

1. Environ("computerName") 'Displays Computer name
Environ(5) 'Also displays computer name

Public Sub printEnvironmentVariables()

Dim i As Integer

For i = 1 To 33
Debug.Print Environ(i)
Next i

End Sub

ALLUSERSPROFILE=C:Documents and SettingsAll Users
APPDATA=C:Documents and SettingsbaskaraApplication Data
CommonProgramFiles=C:Program FilesCommon Files
HOMEPATH=Documents and Settingsenoy
Path=C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSys tem32Wbem;C:Program FilesMicrosoft SQL Server80ToolsBINN;C:MSSQL7BINN;C:Program FilesMicrosoft SQL Server80ToolsBinn
PROCESSOR_IDENTIFIER=x86 Family 6 Model 7 Stepping 3, GenuineIntel
ProgramFiles=C:Program Files
USERPROFILE=C:Documents and Settingsenoy
VS80COMNTOOLS=C:Program FilesMicrosoft Visual Studio 8Common7Tools


NOTE : In windows 98, the following function wont work to get the computer name.

For eg:, environ(5) or environ("ComputerName") may be null value.

So the following program helps to get the local computer name

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private mstrComputerName As String

Public Function GetTheComputerName() As String

mstrComputerName = Space(250)
GetComputerName mstrComputerName, Len(mstrComputerName)
' Here trimming and removing the last character of unwanted string

mstrComputerName = Mid(Trim$(mstrComputerName), 1, Len(Trim$(mstrComputerName)) - 1)
GetTheComputerName = mstrComputerName

End Function

Private Sub Form_Load()
End Sub

If any issues or suggestions, contact me @


Find A String Line Wich String Value Is Unknow

'You have probably meet this kind of question

Dim objWdRange As Range
Dim objWd1 As Range
Dim Num1 As Integer
Dim NumLines As integer

Selection.GoTo wdGoToLine, wdGoToLast
NumLines = ActiveDocument.BuiltInDocumentProperties(wdPropertyLines)
Selection.GoTo wdGoToLine, wdGoToFirst
Selection.Expand wdLine
Set objWd1 = Selection.Range 'receive the string of the first line
Selection.Collapse wdCollapseEnd
Set objWdRange = ActiveDocument.Range(Start:=lStart, End:=ActiveDocument.Content.End)
With objWdRange.Find
.MatchCase = True 'or False
.Text = objWd1 ‘here is my problem I can’t put a string because I don’t know the
‘the value of this string .I but objWd1 as a variable .But as I have wrotten it is false .
'(NB to understand
‘purpose Every time I open a text , the macro must find all the lines wich have been repeated , deletes all the occurences save a line among
'them. )

bFound = .Execute
End With

'there is no bug but the string line seems not to be researched

If bFound Then
Set objWdSelection = Application.Selection
objWdSelection.Expand wdLine 'selectionne toute la ligne
objWdSelection.Text = "not easy" & vbCrLf
End If
lStart = objWd1.Start + 1
Loop While bFound

Find And Replace Text String In A Text File.
I have a text file - "PumpList.txt". I want to find the text string "Pump1" in this file and replace it with the string "Pump 101". I have found search and replace code examples but they all work on Text Boxes, not text files. I am having difficulty understanding how to open a text file and search for a text string and then replace it with a different string. I am using VB6. Any help would be greatly appreciated and some example code would help even more. Thank you.

Using A Program To Find Files. Without Using Apis To Call Up Windows Find
i would like to locate a file using straite code in viaula basic

can you help me out??


How Can I Find Whether There Any Keyboard Or Mouse Events Like Screen Saver Find
I am in search of function which will help me find out my system is ideal or not ( like screen savers run after a particular time when there is no events in given time) I also wants to run a program which will run if there is no event of keyboard or mouse. This function I want to used in one program.

If anybody know please help me out.


How To Find A The Character In A String At A Certain Position In The String
how to find a the character in a string at a certain position in the string

such as:


i want to find position 2 which is 'e'

Copyright © 2005-08, All rights reserved