473,396 Members | 1,726 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,396 software developers and data experts.

Find Next function for search with Like operator

I am using this code to search with wild cards for strings in a text file. I wanted to improve the application by adding a "Find Next " button that will display the rest of the strings that the search initiated by the Function SearchString finds. For example the initial search for "*out" will result in displaying "doubt" in Lbltext1Caption and the debug.print would list more strings found at certain lines. How can I employ a second button that can progressively display the remainder of the strings found. I have tried and searched very hard for this with no luck, so any help will be greatly appreciated. This forum has been very helpful for me in the past and people here proved very knowledgeable. I know I am in the right place so please help!


Expand|Select|Wrap|Line Numbers
  1. Private Function SearchString() 
  2.  
  3. Dim Fnum As Long, Buffer As String, LineNo As Long 
  4. index1 = (LineNo) 
  5. LineNo = -1 
  6. Fnum = FreeFile  
  7.  
  8.   filename = ("C:\windows\temp\file.txt") 
  9.   thestring = TxtSearch.Text 
  10.  
  11.   Open filename For Input Access Read Shared As #Fnum 
  12.  
  13.   Do Until EOF(Fnum) 
  14.     ' Retrieve one line of text from the file a string. 
  15.     Line Input #Fnum, Buffer 
  16.     LineNo = LineNo + 1 
  17.  
  18.      If LCase$(Buffer$) Like "*" & LCase$(thestring$) & "*" Then        
  19.  
  20.      = line_value1(index1) 
  21.  
  22.       Debug.Print "Found string at line: "; Format(LineNo) 
  23.        End If 
  24.        Loop 
  25.  
  26.   Close Fnum 
  27.  
  28. End Function
  29.  
  30.  
  31.  
Feb 10 '10 #1
0 1255

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

Similar topics

4
by: Tom | last post by:
Hi, I need some help with stl maps. I am using a std::map that is sorted in a very special way. Therefore I am using my own sort function. That works fine. But this is only half the problem....
3
by: John J | last post by:
I am in the process of writing 3 associated classes to store details of yacht racing information. Below is a section of code from my Entry class. An entry object is created as follows "Entry e1...
3
by: Liz Malcolm | last post by:
Hello and TIA for guidance. I am building a reusable search procedure (thanks go to Graham Thorpe for his example that set me on my way). Everything works up until the 2nd match is found, the...
8
by: jquest | last post by:
Hi Again; I have had help from this group before and want to thank everyone, especially PCDatasheet. My database includes a field called HomePhone, it uses the (xxx)xxx-xxx format to include...
0
by: Popoxinhxan | last post by:
Hi guy , i would like to have a Find search function like in Ms Excel to search for specific keyword in the list view. Could anyone help me to do so. Currently i can only get the index of the item...
5
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
7
by: tehn.yit.chin | last post by:
I am trying to experiment <algorithm>'s find to search for an item in a vector of struct. My bit of test code is shown below. #include <iostream> #include <vector> #include <algorithm>...
2
by: yuvalbra | last post by:
I work in asp envirments. i get the ref url that come to my site and i want to convert it to find out what was the query in (google or other searcher sites) foe example : if someone goes to...
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
4
by: lightaiyee | last post by:
Dear Gurus, I would like to implement a function that computes the number of times a certain condition is met in a global array. For example, I have an global array of size 500. float array;...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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...

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.