User Profile
Collapse
-
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... -
bugs in seach function
I am having 2 problems with a searfch function that I am hoping you could help me with. I am using a label to trigger a search and want it not to search when the textbox is blank. So I am using this code:
However, the code doesn't work because the search function seems to be triggered anyways and generates an error. How could I prevent the search funtion from running when the textbox is blank.
The second issue... -
Thanks vb5prgrmr for your help. I figured out the combination through trial and error.
It's ironic how, sometimes, the solution turns out to be very simple after believing that you are dealing with a major problem. All I had to do was turn the "If Buffer..."
into "If Like ..." statement and it worked fine for what I need. Thanks again. -
Sorry, but I don't have the vb6 help installed! I discovered that I was having problems locating a complete expression such as "To be able to" and displaying it in a label; so I switched to another code by Killer42 that checked if line exist in a file ;and it works fine for non-case sensitive searches. Here is how I incorporated it:
Then I found this code that uses wild cards in the search and I am wondering...Leave a comment:
-
The only scenarios that might come up in my situation are the case sensitive and the spaces issues -- there are no punctuation marks at all. The file to be searched is made up of one word or one short expressions on each line. So I need to be able to find "Adjusment" if I type "adjust" or "adjust*" and to find "To adopt" by typing "adopt" or "*adopt". The code as it stands right now does...Leave a comment:
-
Thanks for the quick response vb5prgrmr.Actua lly I tried to add "vbTextComp are" after TheString "InStr(1, S, TheString, vbTextCompare)" and kept getting type mismatch error, so I did it with the LCase$ and it worked ok. As far as the second part of your response, I only need the asterik to be at the beginning or the end of the word I am looking for, and not in the middle of it. If you meant I should be good with that, I would...Leave a comment:
-
Adapting Function StringExistsInFile by killer42
I am using the code below that was posted by killer42 in order to search for words in a textfile. I added the LCase$ to (S) and (TheString) so case would be ignored. I was wondering if the code could, just as easily, be adapted to accept a wildcard (*) at the beginning or end of the string to search for; in other words to be able to look for "*djust " and get "adjust" and look for "adjust*" and get "adjustment "... -
I was inclined to think that it wasn't the code but when it happened on more than one machine I thought it best that someone with more knowledge look at the code and see if I overlooked something. It's likely that this problem is related to winxp with a specific service pack. Anyways, is it possible to have the code "force" the execution of reading the first label before it moves to the next label and check if it has to read it.
...Leave a comment:
-
moody DirectSS1
I have an unusual problem where the following code works fine on many winxp machines while it doesn't on some others. The Directss1 is supposed to read first Lbltext1, then read Lbltext2 (if not hidden) and finally Lbltext4 -- again if not hidden. As I said it works fine on most machines but on others it reads only the last label in the sequence. In other words if all labels are showing and not hidden, it will only read Lbltext4. But if that label... -
I am wondering if index1 is set as 1 by default in vb.net and cannot be changed this way. All I am trying to do is, by using a command button or a timer, display the data sequentially, one line at a time.But I want to be able to control the start and end points in the data. Thanks for your attempt at helping out.Leave a comment:
-
I meant it doesn't work as it should. The label will display the line_value at line #10, but doesn't move to the next line as in the original where it keeps going till the end of the data. Consequently there are no exceptions.Leave a comment:
-
changing value of index1
This piece of code
works fine as long as I don't change the value of index1.Code:If index1 < 1323 Then index1 = index1 + 1 Else 'MsgBox "This is the last record of the data" Label1.Caption = line_value1(index1) End If
As soon as I insert index1=50 then it doesn't work right.
It worked fine in vb6 but not in vb.net. Any ideas why it doesn't work.... -
storing decoded files in memory instead of temp file
I was wondering if in VB6, the contents of a decoded file could be stored in memory instead of in a temporary file. I found out that this could be done in VB.Net right "after using DecodeToByte to obtain the file contents, you would then convert the byte data to a string which can be manipulated as needed:". The code to use is:
[CODE=vbnet]'Decode file from base64
Dim bt64 As Byte() = DecodeToByte(sr c1)
'Convert... -
So why doesn't Trent's code work even after I define "index " as long and then initialise it as = index1? Could you take a closer look at that because this is really driving me nuts.
It was simpler and it worked fine when I had "If Index1 > 1" and when it went back to the beginning of the record!
Did I do this the right way whe I "Dim index as long" and then
initialised "...Leave a comment:
-
That's true killer42, I got the error that index is not defined.The code for the Next and the Previous are :
...Code:Private Sub CmdN_Click() If index1 < index2 Then ' I am using index2 as upperlimit index1 = index1 + 1 Else MsgBox "This is the last record of the data" End If lbltext1.Caption = line_value1(index1) Private Sub CmdR_Click() IfLeave a comment:
-
Trent, thanks for the help, but that didn't work either .As soon as I hit the previous button I get the message no matter what the position in the file is at that time. I was told that I need three variables for lowerlimit, upperlimit and currentposition -- but I still don't know if to use a for loop or do while or whatever. Any suggestions on that?Leave a comment:
-
code for previous comand button
This has to be very simple but I can't get it right and I'm getting frustrated with it. My code for the Next button works fine while using "index1" for lowerlimit and "index2" for the upperlimit and it goes like this :
...Code:If index1 < index2 Then index1 = index1 + 1 Else MsgBox "This is the last record of the data" End If -
Great ending for the thread.It couldn't have been "scripted" any better.Another person benefits from the same thread.
gdijim], great that you found it helpful.I've been working on this for a while too and visited many forums.This place though tops them all because the help was right there, right away thanks to moderators like Killer42. By the way,I found the article you mentioned and will probably make use of it.
Thanks...Leave a comment:
-
I got it ! finaly.. I had to change the statement to read
lowerlimit+ Rnd * (upperlimit - lowerlimit)
and it seems to work..
Thanks again for your help and I '' be dropping by to learn from this forum...Seems people quite helpful here.Leave a comment:
-
I am back ..it seems like after I set the upper and lower limits, the random statement for choosing the next item doesn't work anymore:
Int ( Rnd * uppernumber ) +1
as this was useful for numbers between 1 and 1000. What needs to be changed here to control that the numers that are chosen are between 600 and 900 for example?Leave a comment:
No activity results to display
Show More
Leave a comment: