473,659 Members | 3,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InStr function Position Glitch

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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strGetWords As Long
  3. strGetWords = InStr(1, Text6(0).Text, " " & Text1.Text & " ", vbTextCompare)
  4. If strGetWords = 0 Then
  5. Text1.Text = "?"
  6. Else
  7. Text6(0).SetFocus
  8. Text6(0).SelStart = strGetWords
  9. Text6(0).SelLength = Len(Text1.Text)
  10. End If
  11.  
  12.  
What's the problem now?

Well I'll tell you...Let's go to commercial first...
Jan 13 '07 #1
11 1698
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strGetWords As Long
  3. strGetWords = InStr(1, Text6(0).Text, " " & Text1.Text & " ", vbTextCompare)
  4. If strGetWords = 0 Then
  5. Text1.Text = "I get nothing here"
  6. Else
  7. Text6(0).SetFocus
  8. Text6(0).SelStart = strGetWords
  9. Text6(0).SelLength = Len(Text1.Text)
  10. End If
  11.  
  12.  
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?
Jan 13 '07 #2
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strGetWords As Long
  3. strGetWords = InStr(1, Text6(0).Text, Text1.Text, vbTextCompare)
  4. If strGetWords = 0 Then
  5. Text1.Text = "Wheels"  Got this from TheWheels
  6. Else
  7. Text6(0).SetFocus
  8. Text6(0).SelStart = strGetWords
  9. Text6(0).SelLength = Len(Text1.Text)
  10. End If
  11.  
  12. 'Text6(0).SelStart = strGetWords -1 did not do the trick
  13.  
  14.  
  15.  
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
Jan 13 '07 #3
Killer42
8,435 Recognized Expert Expert
You might want to try this slight modification to your code (I'll highlight the modified bit)...
Expand|Select|Wrap|Line Numbers
  1. Dim strGetWords As Long
  2. strGetWords = InStr(1, " " & Text6(0).Text & " ", " " & Text1.Text & " ", vbTextCompare)
  3. If strGetWords = 0 Then
  4.   Text1.Text = "I get nothing here"
  5. Else
  6.   Text6(0).SetFocus
  7.   Text6(0).SelStart = strGetWords
  8.   Text6(0).SelLength = Len(Text1.Text)
  9. End If
Jan 13 '07 #4
Dököll
2,364 Recognized Expert Top Contributor
Still attempting to diagnose Position Glitch in

Expand|Select|Wrap|Line Numbers
  1.  
  2. strGetWords = InStr(1, Text6(0).Text, " " & Text1.Text & " ", vbTextCompare) ...
  3.  
  4.  
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Text6(0).SelStart = P - 1' I get an invalid use of property  error
  3.  
  4.  
I commented it out Text6(0).SelSta rt = 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.Word FoundInText", 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 :-)
Jan 13 '07 #5
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strGetWords As Long
  3. strGetWords = InStr(1, " " & Text6(0).Text & " ", " " & Text1.Text & " ", vbTextCompare)
  4. If strGetWords = 0 Then
  5. Text1.Text = "?" ' for 'and' I get ?
  6.  
  7.  
I will keep going...
Jan 13 '07 #6
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
Jan 13 '07 #7
Dököll
2,364 Recognized Expert Top Contributor
Got it, thanks, Mary...
Still learning how this works.

Make it a great week-end!
Jan 13 '07 #8
Dököll
2,364 Recognized Expert Top Contributor
I guess this also involves punctuation, correct!
Jan 13 '07 #9
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
Jan 13 '07 #10

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

Similar topics

5
309881
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 some key functionality I need. Here is an example of the Oracle code: if Instr( sTg , cDelim, 1, 3 ) > 0 then sd := SubStr( sTg, Instr( sTg , cDelim, 1, 1 ) + 1, Instr( sTg, cDelim, 1, 2 ) - Instr( sTg , cDelim, 1, 1 ) - 1)
1
25819
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 helful to you: /*************************************************************************** Description: Looks for a string inside another string and returns an integer that correspond to the position of first ocurrence.
11
2999
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 only happens in IE. And the <hr> causes this thing to happen. Now, I have ~tried~ to make this glitch, and that is tough to do. I had did it that one time, and I should have saved the work. But I didn't save the work :(
3
72988
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
6
4000
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" instr(string1,">")
4
3914
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. ie "McCarthy,John Doe Willy". I have to split up Familyname and the 1st FirstName. The FamilyName works perfect, just looking up the comma with InStr and use Left(). Now can someone throw me a bone to help me get the 1st Firstname. "John" according...
12
2968
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 ideas?
2
2186
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, SearchChar, 0) ' Comparison is binary by default (last argument is omitted). MyPos = Instr(SearchString, SearchChar) ' Returns 9. MyPos = Instr(1, SearchString, "W") ' Returns 0.
6
2562
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
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8748
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.