473,473 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB 6.0 Professional + execute Left() function through module

Dököll
2,364 Recognized Expert Top Contributor
Hey VB Gang!

I attempted to send this previously but failed. behold the introduction of a newbie :-)

Anyway, I am hoping t find a shortcut to fixing a problem. Modifying a text reader software which is supposed to pick only the words I tell it, "Bicycle" as one example:

My form

Dim GoSplit As Variant
Dim strGetWords As String

FileName = "\usermate.txt"
f = FreeFile
Open App.Path + FileName For Input As 1
Do While Not EOF(f)
Line Input #1, strLine
GoSplit = Split(strGetWords, " ")

If InStrB(strGetWords$, "bicycle") <> 0 Then

'Left() would have picked up "Bicycle"
'InStrB is grabing everything in sight, provided the're somewhat alike like motorcycle

Text2(0).Text = "Bicycle"
End If

I should have used Left() here. Nonetheless I do not have the time to modify the code, my client leaves in aweek to test it.

My Module

Dim MyStr As Variant
Dim GrabMore As String
Public Sub SendOnly()
GrabMore = LyricalContentfind.Text2(0).Text
MyStr = Left(GrabMore, 7)
'hoping to grab only bicyle's 7 characters
'for the time being I am also gettin "cycle" NOT IN THE CODE...
'I get cycle when motocycle is found in the text.

If Left(GrabMore, 7) <> "" Then 'first value performed
LyricalContentfind.Text2(0).Text = "Bicycle"
Else
MsgBox("No words here fun boy!")

'only if there are no words were found, should above come up

LyricalContentfind.Text2(0).Text = ""

End If

End Sub

If you can point me to a solution, it would be great. I am also a VB fan, and would rather make the code do what I want. Any sort of hints you have is appreciated. Have a great week All!

Dököll
Nov 5 '06 #1
14 5694
Killer42
8,435 Recognized Expert Expert
Hi Dököll.

Sorry, but maybe I'm a little slow - I just could not make out exactly what the problem is. Could you please try to give us a brief summary of what you want the code to do, and in this case perhaps what you don't want it to do?
Nov 6 '06 #2
willakawill
1,646 Top Contributor
Line Input #1, strLine
GoSplit = Split(strGetWords, " ")

Dököll
Hi, what exactly do you expect to find in strGetWords?
You have just declared this variable and stored nothing in it.
Nov 6 '06 #3
Dököll
2,364 Recognized Expert Top Contributor
First off, I would like to thank you for your prompt reply and I apologize for the typo, strLine does not exist in the code: Line Input #1, strGetWords, Not Line Input #1, strLine ' I am attempting to read a file already created...

strGetWords grabs Bicycle and outputs both Bicycle and cycle
GoSplit reads the whole TEXT file

If motorcycle is found in the text, I do not want cycle to be outputted. It seems like strGetWords is forcing part of text out regardless my efforts to control it with the Left() function in a module.

Any direction you have is appreciated.

Dököll
Nov 7 '06 #4
willakawill
1,646 Top Contributor
First off, I would like to thank you for your prompt reply and I apologize for the typo, strLine does not exist in the code: Line Input #1, strGetWords, Not Line Input #1, strLine ' I am attempting to read a file already created...

strGetWords grabs Bicycle and outputs both Bicycle and cycle
GoSplit reads the whole TEXT file

If motorcycle is found in the text, I do not want cycle to be outputted. It seems like strGetWords is forcing part of text out regardless my efforts to control it with the Left() function in a module.

Any direction you have is appreciated.

Dököll
Perhaps the InStr() function will work better for you. It will not pick up motorcycle when you are testing for bicycle. Make sure it is set to vbTextCompare
Nov 7 '06 #5
Killer42
8,435 Recognized Expert Expert
Perhaps the InStr() function will work better for you. It will not pick up motorcycle when you are testing for bicycle. Make sure it is set to vbTextCompare
Although I admit to much difficulty in determining exactly what the question was, I think the problem referred to here is picking up parts of words (Eg. look for "cycle", find "Bicycle" and/or "motorcycle") when they are not wanted In which case, Instr may not help.

In other words, it sounds as though the OP wants a "non-absolute" scan, as we would call it at work, rather than an "absolute" scan, which finds text anywhere.

I don't have more of an answer, because as stated above, I don't yet understand the question. But I'm trying, really I am...
Nov 7 '06 #6
Dököll
2,364 Recognized Expert Top Contributor
Perhaps the InStr() function will work better for you. It will not pick up motorcycle when you are testing for bicycle. Make sure it is set to vbTextCompare
I think I will try that, thanks, I will let you know
Nov 8 '06 #7
Dököll
2,364 Recognized Expert Top Contributor
Although I admit to much difficulty in determining exactly what the question was, I think the problem referred to here is picking up parts of words (Eg. look for "cycle", find "Bicycle" and/or "motorcycle") when they are not wanted In which case, Instr may not help.

In other words, it sounds as though the OP wants a "non-absolute" scan, as we would call it at work, rather than an "absolute" scan, which finds text anywhere.

I don't have more of an answer, because as stated above, I don't yet understand the question. But I'm trying, really I am...
My apologies, here is a simpler version, although by th time you read this I would have figured this out, I think vbTextCompare may do the trick, I intend to read up on it.

Dim GoSplit As Variant

'should grab everything in the file, strGetWords will handle "Bicycle"

Dim strGetWords As String

FileName = "\usermate.txt"
f = FreeFile
Open App.Path + FileName For Input As 1
Do While Not EOF(f)
Line Input #1, strGetWords
GoSplit = Split(strGetWords, " ")

If InStrB(strGetWords$, "bicycle") <> 0 Then

'Left() would have picked up "Bicycle"
'InStrB is grabing everything in sight, provided the're somewhat alike like motorcycle

Text2(0).Text = "Bicycle"
End If



here's the problem:

If InStrB(strGetWords$, "rain") <> 0 Then

Text2(3).Text = "Rain"
End If

I got Rain when B[rain] is picked up in the string, Brain is not in the code. Iwant the program to grab only the words I specify. Please write again if this not clear, I seem to confuse a lot of people. In a bit :-)
Nov 8 '06 #8
Killer42
8,435 Recognized Expert Expert
Sorry, I'm in a rush right now, but what about if you do a loop through the array in GoSplit and simply compare each one to the string you're looking for ("cycle", "rain" or whatever) - no Left, Instr or any other functions required.
Nov 8 '06 #9
Dököll
2,364 Recognized Expert Top Contributor
Sorry, I'm in a rush right now, but what about if you do a loop through the array in GoSplit and simply compare each one to the string you're looking for ("cycle", "rain" or whatever) - no Left, Instr or any other functions required.
That's OK, I am bouncing off the walls these days..but I am at it as we speak and will report back to you guys soon. In a bit...
Nov 9 '06 #10
Dököll
2,364 Recognized Expert Top Contributor
Perhaps the InStr() function will work better for you. It will not pick up motorcycle when you are testing for bicycle. Make sure it is set to vbTextCompare
Here goes:

(1) vbTextCompare did not seem to work, but I kept on with InStrB, like you said, for my sake anyway, being a newbie and all. Anyway, I learned it the hard way and the code is doing what I want to a T. Lukilly, my friend and client gave me more time to complete the project...I feel bad about it because this was to be the trial product

(2) the answer can be simpler and is lurking about, I am sure, perhaps after postings my findings, you can see what I really hoped to achieve. Tackle it for the next version, I still worry of speed of the application.

That said. Being that strGetWords was taking in any word matching "rain" thus train, brain, grain, drain. I saw it best fitting to simply disable the darn textbox that would have carried "rain" if in case "Insane in the brain" is part of the text, I'd rather "rain" not picked up. Here is what the code looks like now:


If InStrB(strGetWords$, "train") <> 0 Then 'train is available, give me Trains

Text2(3).Text = "Trains"
Text4(1).Visible = False

'I do not need "Rain" to be shown since train is the true value...An empty string did not seem to work here (not sure why) so I had to set Text4(1) visibility to false.

End If

If InStrB(strGetWords$, "train") = 0 And InStrB(strGetWords$, "rain") <> 0 Then

Text4(1).Text = "Rain" ' Looking to pick up only "rain", thus to outputting "Rain"
Text2(3).Visible = False 'just in case, I want this invisible
End If

Here there you have it...an ugly way of doing this but that's the solution that is working.

Nevertheless, I need your help figuring out a simple way to achieve this. I could have added a Do while loop, having x as interger, respectfully (x), where x is part of an array to what I need to find in each textbox (Example: Text2(x), Text4(x). I think strGetWords$ will still add "Rain" in my textbox even then when train or similarly brain is found. Please tell me your thoughts on this...

Dököll
Nov 18 '06 #11
rani deshmukh
2 New Member
hi,
thanks to joining me in ur community,
i have problem in visual basic project development means in exact to make a perfect project what kind of skills reuired, n to make that give me idea to how they can design ,coding skill,development skill,how diagnosis the error,arrangment of project,every things related to development of project in visual basi 6.0 and visual basic which having new things founded by r&d developers,plz give me reply






thanks
rani deshmukh
Nov 18 '06 #12
willakawill
1,646 Top Contributor
Here goes:

(1) vbTextCompare did not seem to work, but I kept on with InStrB, like you said, for my sake anyway, being a newbie and all. Anyway, I learned it the hard way and the code is doing what I want to a T. Lukilly, my friend and client gave me more time to complete the project...I feel bad about it because this was to be the trial product

(2) the answer can be simpler and is lurking about, I am sure, perhaps after postings my findings, you can see what I really hoped to achieve. Tackle it for the next version, I still worry of speed of the application.

That said. Being that strGetWords was taking in any word matching "rain" thus train, brain, grain, drain. I saw it best fitting to simply disable the darn textbox that would have carried "rain" if in case "Insane in the brain" is part of the text, I'd rather "rain" not picked up. Here is what the code looks like now:


If InStrB(strGetWords$, "train") <> 0 Then 'train is available, give me Trains

Text2(3).Text = "Trains"
Text4(1).Visible = False

'I do not need "Rain" to be shown since train is the true value...An empty string did not seem to work here (not sure why) so I had to set Text4(1) visibility to false.

End If

If InStrB(strGetWords$, "train") = 0 And InStrB(strGetWords$, "rain") <> 0 Then

Text4(1).Text = "Rain" ' Looking to pick up only "rain", thus to outputting "Rain"
Text2(3).Visible = False 'just in case, I want this invisible
End If

Here there you have it...an ugly way of doing this but that's the solution that is working.

Nevertheless, I need your help figuring out a simple way to achieve this. I could have added a Do while loop, having x as interger, respectfully (x), where x is part of an array to what I need to find in each textbox (Example: Text2(x), Text4(x). I think strGetWords$ will still add "Rain" in my textbox even then when train or similarly brain is found. Please tell me your thoughts on this...

Dököll
Where is this word 'Train' or 'Brain' coming from and where is the strGetwords string coming from?
Nov 18 '06 #13
Dököll
2,364 Recognized Expert Top Contributor
Where is this word 'Train' or 'Brain' coming from and where is the strGetwords string coming from?
Where is this word 'Train' or 'Brain' coming from and where is the strGetwords string coming from?
Hello! strGetWords is dimensioned as string, GoSplit as variant: Train is being added in large textbox, capable of recording at least 300 to 400 words,m in a lyrical text, for example. Glad you wrote by the way, I found out something else: while I managed to make textbox invisbl thus to not carry rain, I find that "Bus" is being added to its textbox, Text4(9).Text when "busted", is found. My analysis brought me to yet another simple solution--"Busted" having a cap first letter dos not ght picked up, so I decided to convert all lowercased "busted/s" to Uppercase,then say, give nothing when BUSTED is found, it works well and here is the code again, See module, as well (part of the solution

Dim GoSplit As Variant
Dim strGetWords As String

FileName = "\usermate.txt"
f = FreeFile
Open App.Path + FileName For Input As 1
Do While Not EOF(f)
Line Input #1, strGetWords
GoSplit = Split(strGetWords, " ")

If InStrB(strGetWords$, "busted") <> 0 Then

Text4(9).Text = "busted"
convert_my_text="BUSTED"
convert_me_modu.change_it_now 'this fires up my module named conert_me_modu
End If

My Module

Public convert_my_text As String

Public Sub change_it_now ()

If UCase(convert_my_text) = "BUSTED" Then
'first value performed
LyricalContentfind.Text4(9).Text = ""
'empty string works here, no need to set vsibilty to false
End If

End Sub
Nov 26 '06 #14
Dököll
2,364 Recognized Expert Top Contributor
Where is this word 'Train' or 'Brain' coming from and where is the strGetwords string coming from?
HAPPY NEW YEAR VB Fans!!! Hopefully, we continue battling against VB for years to come, unless Microsoft makes this steadily unusable, there's probably big plans when Vista is "Fully" operational, hee, hee...

My friends, Killler, WillAkaWill, VB friends accross the country, I thank you for your support and patience. I think we are almost there. Much appreciated help, by the way, with the code, especially adding the below to the mix. The code works great, but does not seem to be doing what you told me Killer; of course, I am to blame for being a newbie and all. Seems as though, a text file does not abide by rules of certain databases, where VB would be reading from cells containing text/word as opposed to a block of text/words in a .txt file. What do you see happening, I am blind back here. Send me some brain waves, will you?

Should I set a character length I am certain is reachable, whereby one word in the program supports the highest possible character length, 13 characters for lightningbolt...I have been in and out of the code trying diffrent things, my latest brought me to:

Expand|Select|Wrap|Line Numbers
  1.  
  2. temp$Left$(strGetWords$, 13)
  3.  
  4. temp$=LCase(StrGetWords$)
  5.  
  6.  
I need a do while loop here, that will check to see if any characters were met, meaning:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Do While temp$ <= 13
  3.  
  4. ' then have if statements here to grab anything that falls under 13 chars.
  5.  
  6.  
Would you tell me if this is possible? Works by itself and grabs characters already set. Any idea you can provide is helpful. This was an attempt to stay away from looping, I kept getting stuck in a loop:

Expand|Select|Wrap|Line Numbers
  1.  
  2. temp$ = LCase(strGetWords)
  3.  
  4. temp$ = Left$(strGetWords, 4) 
  5. ' this should give me rain or anything in that length catagory
  6.  
  7.  
  8. temp$ = Left$(strGetWords, 5) 
  9. ' this should give me Train or anything in that length catagory
  10.  
  11.  
  12. temp$ = Left$(strGetWords, 6) 
  13. ' this should give me Grains or anything in that length catagory
  14.  
  15.  
  16. ' Version 1 should find any line starting with the 4 letters "rain"...
  17. If temp$ = "rain" Then
  18. Text1.Text = "Rain"    'this and that here...
  19. End If
  20.  
  21. ' Version 2 should find only "rain" as the first word...
  22. If temp$ = "Train" Then
  23. Text2.Text = Text6.Text      'this and that here...
  24. End If
  25.  
  26. ' Version 3 should find any word starting with "rain"...
  27. If temp$ Like "Grains" Then
  28. Text3.Text = "Grains"    'this and that here...
  29. End If
  30.  
  31.  
The only problem here is, the first temp$ variable grabs rain straight away and ignores the other words. I added each word as rain, Train, Grains, and only rain was picked up. My guess is a loop will tell VB to jump over after rain is found in order to find other words from the text box. Any ideas, I know this was a mouth full, Sorry. If the loop is not doable and your previous postings should work please clarify a bit more. :-)
Dec 27 '06 #15

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

Similar topics

5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
7
by: William Gill | last post by:
I have been trying to pass parameters as indicated in the api. when I use: sql= 'select * from %s where cusid = %s ' % name,recID) Cursor.execute(sql) it works fine, but when I try : sql=...
3
by: Lyle Fairfield | last post by:
MS-SQL Server utilities Enterprise Manager and Query Analyzer will model almost any MS-SQL object as a simple script file with a default ".sql" extension. But how to "run these files? They are...
2
by: ben | last post by:
I have the following code in a VBA module: DoCmd.RunSql "Update tData Set sd = Log(Strike/Price) where symbol = '" & symbol & "'" This statement worked fine, and was using the built in math...
1
by: Scott Chang | last post by:
Hi all, 1)I used Microsoft Visual C++.NET (2002) on my Windows Me and Windows XP Home Edition for the last one and half years. 4-5 weeks ago, I upgraded my PC from Windows XP Home Edition to...
4
by: Ian Kelly | last post by:
Hi All, I have an .net form that is split into two frames. The left frame has a tree that displays a list of all the customers. The right frame displays the appropriate clients information. ...
2
by: Paul Cheetham | last post by:
Hi, I am trying to execute another application from my VB.Net app. Using the Windows API I would use a WinExec call, but I don't seem to be able to find an equivalent function in VB.Net Can...
2
by: denny | last post by:
Hello, rookie here. I'm trying to import a module at runtime using variables to specify which module, and which functions to execute. for example: mStr = "sys" fStr = "exit" # load mod...
5
by: John | last post by:
Hi Why can't I use Right and Left string functions in vb anymore? Thanks Regards
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
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...
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...
0
agi2029
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.