|
-
May 31st, 2000, 09:20 AM
#1
Thread Starter
Junior Member
Hi there!!
This is a question regarding File I/O.
I created a text file (extension .txt) with the following format:
abc 123.1.2.3 cbefg 128.1.5.6 vwxyz 224.0.0.0 .... etc
The file will starts with a name followed by an IP address, this format will carry on till EOF with no newline characters.
The file format cannot be modified, so the question is how can I extract the names and IP addresses separately?? The names are of different length so the only thing which I can think of is to detect for the spaces in between them, but I am not sure how this can be done.
I will need the names to be in a combo box and upon selecting a name, the corresponding IP address will be displayed in another textbox.
Regards
-
May 31st, 2000, 10:17 AM
#2
Fanatic Member
I think you would be better off using RANDOM file access, where each record has a set amount and format for the data, in your case it could be:
Name
Ip Number 1st Quarter
Ip Number 2st Quarter
Ip Number 3st Quarter
Ip Number 4st Quarter
and you know this much the name is of STRING format and the numbers are of INTEGER format, so you end up at
Public Type MyRecordInfo
Name as string * 30
Number1 as Integer
Number2 as Integer
Number3 as Integer
Number4 as Integer
End Type
Public Type MyRecord as MyRecordInfo
And you would open it as:
Open ThisFile for Random Access as #XX Len=Len(MyRecordInfo)
And you load save records by using:
to load it
Get #XX, ThisRecordNumber, MyRecord
to save it
Put #XX, ThisRecordNumber, MyRecord
That way you can pull up any record you wish
I hope that helps you,
If you need more info just e-mail me or post a reply
NOTE:
For more info look in the help under:
Open
Access
Random
Type
User Defined Types
DocZaf
{;->
-
May 31st, 2000, 02:00 PM
#3
Thread Starter
Junior Member
But my source text file is in a whole string format without any newline characters in between, do u think it can work??
Thanks!
-
May 31st, 2000, 02:12 PM
#4
-
May 31st, 2000, 02:21 PM
#5
Thread Starter
Junior Member
hi Jason!
Would really appreciate that! cos I really need an example to get going!!
Thanks alot!!
-
May 31st, 2000, 11:22 PM
#6
New Member
Hey here's an example that might work
let x= string
let p() matrix of strings of terrible length (much bigger than size you need)
dim Array_Index
dim Counter_Var
dim Position_Var
Array_Index = 0
Position_Var = -1
while not Position_Var = 0 do
Position_Var = InStr(x, " ") ' now looking for space
P(Array_Index) = Mid(x , Position_Var + 1, 15) 'take 15 characters after space
Array_Index = Array_Index + 1
Loop
This is rough but the idea is sound. You will need to check if the thing after the space is a number or not.
Also this is not a programming approach at all, but if you have spaces or other things seperating this stuff you can do a custom replace in word on this file, you just open up the text file in word and replace all spaces with returns or whatever else you want, why would you do this? ....
well later on you can actually read a line in and some of them will be the IP addresses which you wanted originally.... this might also work for you...
Cheers
-
Jun 1st, 2000, 10:08 AM
#7
Fanatic Member
Question
What is it that your trying do?
Are you trying to decipher site traffic logs?
DocZaf
{;->
-
Jun 1st, 2000, 10:36 AM
#8
Junior Member
Use Split Function
Load the file in a text string by using Open FileName as...Close #FileNum. Then use split function to store it in an array. Do a loop to read values.
For I = 0 To Strings.UBound Step 2
lstIP.AddItem Strings(I) & ": " & Strings(I+1)
Next I
Assuming that there is an array containing Data and An Listbox in which the Contents will be loaded such as:
YAHOO!: 202.54.61.1
VBWIRE: 422.45.31.0
And so on....
Kazim Zaidi (the cracker)
-
Jun 1st, 2000, 10:39 AM
#9
Hyperactive Member
You could write your own code to break up the string or use the built in function 
http://www.informit.com/content/0789...html#Heading10
"People who think they know everything are a great annoyance to those of us who do."
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
|