Dököll 2,364
Recognized Expert Top Contributor
Don't you just love debugginh!
Sent a note to Steve, and my professor on this one. Smile, Killer, you hinted the code may not work as flawlessly as stated. Again, make no mistake about it, Steve's help has made a lot of sense, and yours, and still intend to engrave all names responsible (credits due and given). Going forward, I wanted to debug before screaming at the top of my lungs. And at the risk of making this one a mouth full, I will post several fables to explain the likelihood of drilling a hole in my notebook:-)
My friends, "I can't seem to find the meaning of funky"... if you like progressive house music, you might have heard above track. Anyhoot, my position is lost in the mix: -
-
Dim strGetWords As Long
-
strGetWords = InStr(1, Text6(0).Text, " " & Text1.Text & " ", vbTextCompare)
-
If strGetWords = 0 Then
-
Text1.Text = "?"
-
Else
-
Text6(0).SetFocus
-
Text6(0).SelStart = strGetWords
-
Text6(0).SelLength = Len(Text1.Text)
-
End If
-
-
What's the problem now?
Well I'll tell you...Let's go to commercial first...
11 1688 Dököll 2,364
Recognized Expert Top Contributor
Tonight VB 6.0 Forum, followed by "The Love Boat"...click, click, click, we're back: -
-
Dim strGetWords As Long
-
strGetWords = InStr(1, Text6(0).Text, " " & Text1.Text & " ", vbTextCompare)
-
If strGetWords = 0 Then
-
Text1.Text = "I get nothing here"
-
Else
-
Text6(0).SetFocus
-
Text6(0).SelStart = strGetWords
-
Text6(0).SelLength = Len(Text1.Text)
-
End If
-
-
I get nada if the first position. Example:
"Wheels on the bus goes round and round"
When round is searched Text1.Text = "Round"
When Wheels searched Text1.Text = "I get nothing here"
Let's "analyze this" problem, shall we?
Dököll 2,364
Recognized Expert Top Contributor
I attempted to remove the " " $ and the & " " works just fine, and I do get Wheels, but I also get Wheels in "TheWheels", sounds familiar: -
-
Dim strGetWords As Long
-
strGetWords = InStr(1, Text6(0).Text, Text1.Text, vbTextCompare)
-
If strGetWords = 0 Then
-
Text1.Text = "Wheels" Got this from TheWheels
-
Else
-
Text6(0).SetFocus
-
Text6(0).SelStart = strGetWords
-
Text6(0).SelLength = Len(Text1.Text)
-
End If
-
-
'Text6(0).SelStart = strGetWords -1 did not do the trick
-
-
-
Your turn, Killer, or anyone who sees clearly what I intend to achieve. Just emailed my VB professor about this, he's been out the game, last he wrote; this should spring some interest. Now Killer, your code gives me the same result, Wheels not picked up but round does. Though it rids punctuation just fine, I must have done something silly to it, I am comparing the modified version to your and will post it in a moment...
In a bit, and thanks for your support, and patience.
Dököll
You might want to try this slight modification to your code (I'll highlight the modified bit)... - Dim strGetWords As Long
-
strGetWords = InStr(1, " " & Text6(0).Text & " ", " " & Text1.Text & " ", vbTextCompare)
-
If strGetWords = 0 Then
-
Text1.Text = "I get nothing here"
-
Else
-
Text6(0).SetFocus
-
Text6(0).SelStart = strGetWords
-
Text6(0).SelLength = Len(Text1.Text)
-
End If
Dököll 2,364
Recognized Expert Top Contributor
Still attempting to diagnose Position Glitch in -
-
strGetWords = InStr(1, Text6(0).Text, " " & Text1.Text & " ", vbTextCompare) ...
-
-
Here is what I found out in your beautifully written code, Killer. It is now working and deals with positioning as suspected previously. It was not picking up the first word in "Wheels on the bus..." because of: -
-
Text6(0).SelStart = P - 1' I get an invalid use of property error
-
-
I commented it out Text6(0).SelStart = P - 1 and it works great. Now encountered another glitch. I decided t add the remaining text on the next line as in the below. I am now unable to find "and" but "so" does pop up:
The Wheels on the bus goes round (first line in Text6(0).Text)
and round, if so where...(second line in Text6(0).Text)
Any idea how to remedy this. You have a pretty good idea I amj sure, I simply can't see it:
Please see next posting, your function to fetch puntuation is apparently not working. I wonder if I've done something wrong, Again. The Module added to plug it in is called/and dot-noted " KillerSays.WordFoundInText", I now get an "argument not optional" error. I can't figure out how I made it work.
I am happy with it thus far, I am debugging, see what gives :-)
Dököll 2,364
Recognized Expert Top Contributor
Much appreciated response...
Thanks for adding your two-sense here: I get the same deal as in the previous:
The Wheels on the bus goes round (first line in Text6(0).Text)
and round, if so where...(second line in Text6(0).Text)
"and" is not picked up, "The" is: -
-
Dim strGetWords As Long
-
strGetWords = InStr(1, " " & Text6(0).Text & " ", " " & Text1.Text & " ", vbTextCompare)
-
If strGetWords = 0 Then
-
Text1.Text = "?" ' for 'and' I get ?
-
-
I will keep going...
MMcCarthy 14,534
Recognized Expert Moderator MVP
Just a quick note. Please don't put messages in the title. Just put a question description. This is because the titles are searched by google and the messages just make them harder to find.
Thanks
ADMIN
Dököll 2,364
Recognized Expert Top Contributor
Got it, thanks, Mary...
Still learning how this works.
Make it a great week-end!
Dököll 2,364
Recognized Expert Top Contributor
I guess this also involves punctuation, correct!
MMcCarthy 14,534
Recognized Expert Moderator MVP
Got it, thanks, Mary...
Still learning how this works.
Make it a great week-end!
You too Dokoll.
Thanks
If a line break is causing poroblem, just treat it like punctuation, and convert it to spaces. If you're dealing with individual characters, then you could search for vbCR and vbLF and replace each of them with a space. If number of characters isn't so important, just scan for vbNewLine or vbCRLF and replace with a space.
(This is all just in the temporary copy of the text for searching, of course - not the "real" text.)
Dököll 2,364
Recognized Expert Top Contributor
You read my mind, I was coming here to let you know I found out why the first word on the next line (second line) did not get picked up:
If Text is added in a multiline TextBox, at the end of line, the TextBox forces text to next line (as in text)...If I physically tab or hit enter the word/text typed in afterwards does not get picked. I am about to do exactly what you said; well really I thought add Chr(13), Chr(10) to the list, I have read or heard vbNewLine and vbCrLF runs with both, so this is pretty cool.
Have a good morning, and a great day, I'm tired now...Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: DTB |
last post by:
I am trying to convert a complex function from Oracle to SQL Server
and have come across Oracle's Instr() function. I see SQL Server has
CHARINDEX() which is similar, however it does not provide...
|
by: Icaro |
last post by:
Hi everybody,
I was looking for an equivalent ORACLE INSTR Function in MSSQL but I
don´t found it and I don´t know if it exist so I must to write it and
this is the code. Maybe it will be...
|
by: Ted Mayett |
last post by:
OK. Here is a glitch, sorry if this has been mentioned before.
This is an erratic glitch. I am now up to three other people besides
myself who have been able to see this glitch. It seems it...
|
by: Fancy Pants |
last post by:
Hi everyone,
What is similar to the Instr function that is in ASP, in javascript?
I am trying to search text boxes in a contact form, for certain
characters.
Justin
|
by: Chris Calzaretta |
last post by:
Hello Everybody,
Question
instr function will give you the first instance of the finding
so EX:
so your string looks like
string1 = "testing>This is > just a test > testtesttest"...
| |
by: fischerspooner |
last post by:
Hi,
I'm banging my head against the desk because I can't find a solution for the following simple problem.
Case: There is a column in a table that has FamilyName and FirstName(s) in one field....
|
by: rodchar |
last post by:
hey all,
i'm getting a result that i don't understand
i have a string "test1, test2"
If InStr("test1") and InStr("test2") Then
'Inside
EndIf
The inside is not running for some reason. Any...
|
by: Puneet Bhatnagar |
last post by:
A textual comparison starting at position 4. Returns 6.
MyPos = Instr(4, SearchString, SearchChar, 1)
' A binary comparison starting at position 1. Returns 9.
MyPos = Instr(1, SearchString,...
|
by: Brian |
last post by:
what is the equivlant of the vb 6 instr
I have a string there has "*D*N"
I want to find the position that the D is in with a dotnet (VB) function
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |