Here it goes again, thanks again for responding:
'PROPOSED SOLUTION 2
'I wanted to not creatre a file and just read straight out of Text6.Text and
'output my findings in legal text boxes
'I also needed/had to, because OF LACK OF EXPERIENCE, figure out wheter my finding was true first
'before out putting, thus Text1.Text = Text6.SelLength = Len(strGetWords) was born
'when true, Text2.Text = strGetWords
'Here is the problem, I searched 'use' by adding it to Text3.Text
'Text3.Text attempt to search below text and Text1.Text will
only be true if use actually exists
'It does, my friends, but in the wrong position, I told VB, Left$(Text3.Text, 3)
'I do not see what the problem is here, STUBBORN BEAST, don't you think!
'Anyway, I found use in beca use, can you believe this?
Here are some instructions, not previously added:
(1)Please make up a form with 3 TextBoxes,
name them Text6, Text3, Text2, Text1,
and one command button, name it strGetWordsTEXT1
or you can do whatever you want
(2)Text6 is set True for multiline, this is where text is added
(3)Text3 is your search box, the word 'use' will be added there
(4)Text2 will carry the word found, use will be visible after you run the code
(5)Text1 is a dummy, it holds either True or false.
If use is found in Text6, it is true, if not, False
(6)Plug in Text below in your Text6
(7)Add use in your Text3
(8)Hit your strGetWordsTEXT1 command button -
Private Sub strGetWordsTEXT1_Click() 'Button to search Text6.Text data
-
-
-
Dim strGetWords, strFromThis ' strGetWords finds the words from strFromThis
-
-
-
strGetWords = LCase(Left$(Text3.Text, 3)) 'my trick did not work here
-
-
-
strFromThis = InStr(Text6.Text, strGetWords)
-
-
-
If strFromThis Then
-
Text6.SetFocus
-
Text6.SelText = Left$(Text3.Text, 3) 'this is not helpng either
-
Text6.SelStart = strFromThis - 1 'starts me off pretty good, but to no avail
-
'I took this out and got and an additional 3 character
-
Text6.SelLength = Len(strGetWords)
-
'use was found, therefore Len record 3 chars, still weak
-
End If
-
-
-
Text1.Text = Text6.SelLength = Len(strGetWords) ' we covered this already
-
-
-
-
If Text1.Text = True Then
-
'use found therefore give priority to Text2.Text
-
-
Text2.Text = strGetWords 'Text2.Text carries use, since Text1.Text is True
-
-
ElseIf Text1.Text = False Then
-
-
MsgBox "Oh lee Molee"
-
-
'this was merely for testing, just in case of a missplell in my word selection
-
End If
-
End Sub
-
-
What am I not doing to the code? If you've ever fet up against the wall...My son knows this as The Project, he's nice but I have a feeling he's growing impatient. I should be able to tell VB do this and it just does it, wouldn't you say. Many thanks, VB gang!
18 1757
So, that word-matching function I wrote for you didn't solve the problem? (Sorry, I haven't seen the thread for a while.)
Is it still the word/string matching that you are stuck on? The message here was a bit overwhelming.
I followed your instructions, and after adding As String to the Dim statement a couple of times (because I always use DefLng and Option Explicit - old habits) it runs. But it seems to have some strange effects.
If I paste "'Anyway, I found it in because, can you believe this" into Text6, put "use" in Text3 and hit the button, what should happen?
What does happen is that it places "use" in Text2, and "True" in Text1. It alsop, and this is the part I find odd, adds "use" onto the end of Text6. So it now contains "'Anyway, I found it in because, can you believe thisuse".
Is it just supposed to tell us whether the word "use" appears in the text? I'll throw together a modified version of the code to do this, but is it what you want?
Here's a quickie which just checks whether the word exists in the text, but as I soon discovered, it doesn't make allowances for punctuation. (In other words, using the example quoted before, it can find the word believe but not because). Should be able to overcome that, but for the moment I have to get back to work. - Private Sub strGetWordsTEXT1_Click() 'Button to search Text6.Text data
-
-
Text1.Text = ""
-
Text2.Text = ""
-
If WordFoundInText(Text3.Text, Text6.Text) Then
-
Text1.Text = "True"
-
Text2.Text = Text6.Text
-
End If
-
-
End Sub
-
-
Private Function WordFoundInText(ByVal Word As String, ByVal Text As String) As Boolean
-
Word = UCase$(Trim$(Word))
-
Text = UCase$(Trim$(Text))
-
If Text Like Word & " *" _
-
Or Text Like "* " & Word & " *" _
-
Or Text Like "* " & Word Then
-
WordFoundInText = True
-
End If
-
End Function
You're a gentleman and scholar, Killer, nice to hear from you. Yes you are correct, use is again added in.
If you delete/comment out: Text6.SelText = Left$(Text3.Text, 3) you will not get the additional use. -
-
strFromThis = InStr(Text6.Text, strGetWords)
-
If strFromThis Then
-
Text6.SetFocus 'keep focus in that Text box
-
'Text6.SelText = Left$(Text3.Text, 3) 'this did not help either
-
Text6.SelStart = strFromThis - 1 ...
-
-
This does not matter much, I think we've got it Killer. Today, the application is 15 percent done. The big idea is this, I simply wanted use to be found by itself, not connected to or associtated with anything (Beca use, useful, etc)...
Will's comment about vbTextCompare stuck, I just could not make it work -
-
If InStrB(strGetWord, "use", vbTextCompare) <> 0 Then
-
this and that, gave me nothing
-
End If
-
-
I revisited vbTextCompare after picking up an email from a friend, who said I would need a 1 up there, thus strGetWords as Long as opposed to String. A slight modification the code provided the below. Truth is both Textboxes should be compared to find one data from one in the other: -
-
'The one that works...
-
-
Private Sub GtWords_Click()
-
Dim strGetWords As Long
-
strGetWords = InStr(1, Text6(0).Text, " " & Text1.Text & " ", vbTextCompare)
-
If strGetWords = 0 Then
-
Text1.Text = "Steve says no way"
-
Else
-
Text6(0).SetFocus
-
Text6(0).SelStart = strGetWords
-
Text6(0).SelLength = Len(Text1.Text)
-
End If
-
End Sub
-
-
Steve's name, yours, Will's and everyone whose assistance and patience helped make this happen will be included in the credits, engraved my friends.
My turn to help :-)
In a bit!
Dököll
I've got a version which I think works perfectly. I'm just leaving work now. When I get home I'll get rid of all the messy commented code and so on, and post it.
Then we'll find out whether I understood what it was supposed to do.
I see from the other thread that you have things working. Oh well, since I wrote the code I might as well post it. Not that I'm complaining :D I love playing with this sort of thing, when I can find the time.
(Are you sure you got exactly what you want out of your code?)
Anyway, here's my version which scans the entered text for the entered word. Looks for full word only, but should work regardless of upper/lower case, and punctuation. (Note, this is all of the code in my project - it's fairly simple.) - ' In the form...
-
Option Explicit
-
DefLng A-Z
-
Private Sub strGetWordsTEXT1_Click() 'Button to search Text6.Text data
-
Dim P As Long
-
Text1.Text = ""
-
Text2.Text = ""
-
P = WordFoundInText(Text3.Text, Text6.Text)
-
If P Then
-
Text1.Text = "True"
-
Text2.Text = Text3.Text
-
Text6.SelStart = P - 1
-
Text6.SelLength = Len(Text3.Text)
-
Text6.SetFocus
-
End If
-
End Sub
-
- ' In a separate module (in case you want to use it anywhere else)...
-
Option Explicit
-
DefLng A-Z
-
-
Private Const AllPunctuation As String = "!.,?:"""
-
-
Public Function WordFoundInText(ByVal Word As String, ByVal Text As String) As Long
-
-
If Text = "" Or Word = "" Then
-
Exit Function
-
End If
-
-
' Standardise the text format.
-
Word = UCase$(Trim$(Word))
-
Text = " " & UCase$(Trim$(Text)) & " "
-
-
' Remove specified punctuation before testing.
-
Dim Char As String * 1, L As Long, I As Long
-
L = Len(Text)
-
For I = 1 To L
-
Char = Mid$(Text, I, 1)
-
If InStr(AllPunctuation, Char) Then
-
Mid$(Text, I, 1) = " "
-
End If
-
Next
-
-
' Scan for word anywhere in text.
-
'If Text Like "* " & Word & " *" Then
-
' WordFoundInText = True
-
'End If
-
-
' Scan for word anywhere in text., return position.
-
WordFoundInText = InStr(Text, " " & Word & " ")
-
-
End Function
It's only had a very quick test, of course.
Great looking code, you got there...Funny you worked out a punctuation find, Steve mentioned the likelihood of having to do that, I'll strip your code, see what I can get....
But Yes, Vol 2 works flawlessly, again if the Text does not have single quotes as in, 'Jack's funny, but driven'. I have added a variable to help handle the quotes, or characters like them, mentioned this in previous reply to you: -
-
strGetWordsOO= Asc("Apple")
-
-
I get what I want everytime:-)
Now, here is something I hve been toying with. For the time, I am using this to clear my TextBoxes, namely Text1, Text2, and Text6. What if I wanted to to loop through the Text added in Text6, and output words found to Text1, Text2:
[code]
Private Sub TextBeGone()
For t = 0 To Text1().UBound
Text1(t).Text = "" 'this handles both Text6, Text2, Text1, for now anyway
Next
End Sub
[code]
For the the Time being, I have Form_Load handle Text into the Text1, Text2 in order to search Text6 input and it works fine. What if I wanted to be fancy?
Killer, Papa was RollingStone! Tae-nae-nae, nae-nae, tuduhh, weeerrrgreee!!! That's guitar, by the way...
Fun, fu-huuunn, what joy to read this code again. Son's now asleep. Sooweeet, Killer. I think I woke up the beast. Works wonders, I wanted to leave my variable in there since: -
-
strGetWordsOO=Asc("Apple's") ' still gives me 65, thus true for Text1
-
-
But ladies and gentlemen, I think we can save ourselves some trouble typing alot of Ascs to get 'Jack Apple's looney bin', not so looney, since no longer a full moon, hee, hee... If this didn't make sense, you can forget about it 'cause it shouldn't, astronomy does this to me, proof I am happy. Great work!!!
Night night chief.
Dököll
To quote the narrator in Kung Pow - Enter the Fist: I'll have some of whatever he's smokin'
hey, we have another thing in common, love kung-fu, took karaté some a while back, ages ago it seems. I am not familiar with Kung Pow, it sounded like the meal Kung Pao (love it lots); my boss actually is chinese, he jokes about the food, not having the same taste, does not know Kung-fu but he seems to like Jackie Chan, not sure if there's a g in there. I like Bruce Lee, saw every film. At the risk of boring you with details though, I think end it with this, Kung-fu as I new it is coming back, there's a new Jet film coming out, must see. Time to get into coding wife's asleep. In a bit!
Here's an idea!
Should anyone need to use a software as dictionary, which is what I started calling my, at least what it used to be 'DICTIONARYMODEL-2-30AM-WORKS... it's a lot longer than this. Anyay, my code can just pick up anything in the clear blue sky anyway. I say psot it, perhaps someone wants to teach French, or English if you're French, Polish, you name it. Have VB grab whatever and translate to whatever: -
-
If InStrB(strGetWords, "Rain") <> = 0 Then
-
MyTextBox.Text1(0).Text = "Rain"
-
End If
-
-
As you have read in previous postings, this would also pick up Rain from Grain, Brain, if we have the wonderful LCase in there, as you said to allow anything R, r to come through. I'll just bet it could work just right. Imagine it: -
-
If InStrB(strGetWords, "Oh la la!") <> = 0 Then
-
MyTextBox.Text1(0).Text = "Oh lee smokes"
-
Else
-
MyTextBox.Text1(0).Text = "Holy smokes" ' just for fun
-
End If
-
-
We'll call this Part on of this project. I am going to go noodle with this one too I think, why not, right!
VB does not like Italic, have you ever heard of this?
VB does not like Italic, have you ever heard of this?
Can you explain what you mean?
(If you copied code from here it should be alright, unless you coped from the Reply window. Then it might have the [i] tags around it, which would certainly upset VB if pasted there.)
Must have thought you could read my mind :-)
I was itching to try the code with different Text formats, so I did with Italic. Testing before I go wild and have to go back in...
You should have seem my face when nothing popped up with the Text Italicized. So, immediately I reverted to regular Text and it works just fine; nothing huge really, my buddy can simply tell his folks add Text as regular. Nevertheless, at the risk of making more work for him, I searched Italic Text re: VB 6.0 in hopes to add a control somehow, now that it is still early in the going and I still have the muscle, anyway, nothing concrete popped up.
I wondered if such a thing exists as to forcing VB to grab Italic Text and convert to regular, I guess what UCase or LCase does to whatever format comes in. Is this possible? If not, it's fine, he's a nice guy he'll understand.
But what are your thoughts on that?
I still don't understand. Where is it you're trying to place this "italic text"? "VB" is a very general term.
Run this and take a look, please ignore the array in Text6, have it the way you want. Text6(0).Text (multiline=True) holds Text, in this case convert the text to Italic before adding it in, Text1.Text is the search box: -
-
Private Sub GtWords_Click()
-
Dim strGetWords As Long
-
strGetWords = InStr(1, LCase(Text6(0).Text), " " & Text1.Text & " ", vbTextCompare)
-
If strGetWords = 0 Then
-
Text1.Text = "Oh no, not on my watch"
-
Else
-
Text6(0).SetFocus
-
Text6(0).SelStart = strGetWords
-
Text6(0).SelLength = Len(Text1.Text)
-
End If
-
End Sub
-
-
Plug in this Text, again convert to Italic before adding to Text6(0).Text:
Copy and Paste text (1) then hit GtWords
Band of the year, you should hear it to believe it. Mr Robinson was not at home at the time of the incident. Short movies, short films are not for short people. Watch out for those manhole covers, this woman almost fell in.
Search for band, or anything you want from above Text, see what happens. I am still running with the code, but like I said and because it is rather rare that Text will be italicized,m I wanted to see if VB can fix this or ignore it. I wonder if the umlaut over my name will be a problem, I hadn't yet checked it. I think I should...
In a bit.
Dököll
I still don't get it. For a plain text box, text is just text. Formatting such as italic/bold is ignored. In fact I would have thought that the RichTextBox control is the only one where a term such as italic has any relevance at all.
Silly me, please disregard this one, You are correct, again, my friend. Too many sleepless nights. I plugged Text not to find, that's why my search came up empty. Works whether Italic or not...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kaptain kernel |
last post by:
i've got a while loop thats iterating through a text file and pumping the
contents into a database. the file is quite large (over 150mb).
the looping causes my CPU load to race up to 100 per...
|
by: Steven Burn |
last post by:
..:: The Specs:
MS Access 2000 (host charges extra for SQL/MySQL)
MS Windows Server 2003 (prod) / MS XP SP1 (dev)
..:: The setup:
The database has been setup with two tables;
tblDownloads
|
by: Diva |
last post by:
Hi,
I have a data grid in my application. It has 20 rows and I
have set the page size as 5. I have a Submit button on my
form and when I click on Submit, I need to loop through
the rows in the...
|
by: fasanay |
last post by:
Hi everybody I have got the following PHP code which I am trying to convert to
ASP any help will be appreciated...I have done most of it but I cant find a
replace function for Unset in asp which...
|
by: Ken |
last post by:
Hi All -
I have a filtered GridView. This GridView has a check box in the first
column. This check box is used to identify specific rows for delete
operations.
On the button click event I...
|
by: Bryan Parkoff |
last post by:
Do you know that current C++ Compiler limits to 64KB segments in source
code? It is good news that Microsoft Visual C++ 2005 has expanded to 4GB
segments in source code. 4GB segment is ideal for...
|
by: Larax |
last post by:
Best explanation of my question will be an example, look below at this
simple function:
function SetEventHandler(element)
{
// some operations on element
element.onclick =
function(event)
{
|
by: Dököll |
last post by:
Hiya, Partners!
I have been into it for 12 hours straight this week-end, my son is very unhappy. Looks like I am getting pretty close but need your help, Again. I will post my first...
|
by: Charlie Brown |
last post by:
I am using something like the following function to loop through a
recipe program I am working on. As I was writing it, I starting
thinking this isn't going to work at all... but not I'm not so...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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...
| | |