473,404 Members | 2,137 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,404 software developers and data experts.

searching for a line in a text file

ok, heres my problem. im trying to make a program that searches a text file with a key word created by the user and prints it in a list box. sorta like a dictionay program in vb.net

heres what i got so far


Expand|Select|Wrap|Line Numbers
  1.  
  2. dim sr as system.io.streamreader=file.opentext.fromfile("file.txt")
  3. dim def, word as string 
  4. def=listbox.text
  5. word=textbox.text
  6.  
  7. do while sr.peek<>-1
  8. word=sr.readline()
  9. listbox.items.add(word)
  10.  
  11.  
this code already fills the listbox with the whole file but i only want the box filled with the definition of the word i placed in the textbox.
Oct 11 '06 #1
1 1604
Please note that instr returns 0 if the work is there on first spot or not found

if instr(word,def) >0 xor String.Compare(word, def, False, 0, def.length) =0 then
listbox.items.add(word)
end if

ok, heres my problem. im trying to make a program that searches a text file with a key word created by the user and prints it in a list box. sorta like a dictionay program in vb.net

heres what i got so far


Expand|Select|Wrap|Line Numbers
  1.  
  2. dim sr as system.io.streamreader=file.opentext.fromfile("file.txt")
  3. dim def, word as string 
  4. def=listbox.text
  5. word=textbox.text
  6.  
  7. do while sr.peek<>-1
  8. word=sr.readline()
  9. listbox.items.add(word)
  10.  
  11.  
this code already fills the listbox with the whole file but i only want the box filled with the definition of the word i placed in the textbox.
Oct 12 '06 #2

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

Similar topics

3
by: hivie | last post by:
I have a problem that is causing me problems. I have a text file that stores 5 lines of crap (stuff that I dont need( for the user only)). After that there is data that is in three columns...
2
by: Mark Reed | last post by:
Hi all, I don't know if this is do-able but you never know until you ask. A situation at work has arisen where I have to trawl through over 500 text files, copy the contents and then paste them...
3
by: Paul H | last post by:
I have a text file that contains the following: ******************** __StartCustomerID_41 Name: Fred Smith Address: 57 Pew Road Croydon
1
by: Bud Dean | last post by:
I need to search files for given text. In particular, I'm searching dll's, exe's, asp, aspx and html pages. I am having difficulty converting the byte arrays to strings. The following code...
2
by: angus | last post by:
hello everybody, i'm having some problems searching a text file and then deleting the line. since i used fileopen(), i can use the eof() function to loop through the file, searching for the...
5
by: robinsiebler | last post by:
I have a batch of files that I am trying to search for specific text in a specific format. Each file contains several items I want to search for. Here is a snippet from the file: .......
2
by: manontheedge | last post by:
Private Sub readFile() Open "example.txt" For Input As #1 Dim sInputData As String While Not EOF(1) Line Input #1, sInputData
3
by: Ahmad Jalil Qarshi | last post by:
Hi, I have a text file having size about 2 GB. The text file format is like: Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values For example...
3
by: Gene Kelley | last post by:
Hello PHPers, I'm trying to get at a single line within a text file. For instance, I want to print the line within a the file named "file.txt" that starts with "17:". file.txt contains...
12
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.