Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer audio backup black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel firefox firefox 3 hard drive internet internet explorer itunes laptop linux malware monitor network networking outlook outlook 2003 outlook 2007 outlook express partition problem router security slow software sound trojan usb video virus vista wifi windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
VB6 String Handling


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
mattpfc's Avatar
Junior Member with 6 posts.
 
Join Date: Jul 2005
05-Jul-2005, 09:04 AM #1
VB6 String Handling
Hi all,

The code attached below is a small extract of machine generated java, which gets dumped into a text file. Each block of code below refers to a process, which had a start point, setFrom, and end point, setTo, and the instruction/verb required to start this, setSelection.

The intention I have is to read each block of code below from the text file, and decipher the 3 main lines I am interested in. So far my code can read each line of code into a string, but I need to know how I can cut out the specfic information from ths line. An example would be:

nodeP1R2.setFrom("SJP_8340_POInv_Input"); = "SJP_8340_POInv_Input"

Thanx in advance


Code:
DKRouteListEntryICM nodeP1R2 = new DKRouteListEntryICM();
nodeP1R2.setFrom("SJP_8340_POInv_Input");
nodeP1R2.setTo("SJP_8340_BuyerRefer_Rework");
nodeP1R2.setSelection("SJP_8340_BuyerRefer_Rework");
routesP1.addElement(nodeP1R2);

DKRouteListEntryICM nodeP1R3 = new DKRouteListEntryICM();
nodeP1R3.setFrom("SJP_8340_POInv_Input");
nodeP1R3.setTo("SJP_8340_TaxRefer_Rework");
nodeP1R3.setSelection("SJP_8340_TaxRefer_Rework");
routesP1.addElement(nodeP1R3);
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,554 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
05-Jul-2005, 11:04 AM #2
I do not know VB6, but I do know Basic and VBA for Access/Excel.
Can you illustrate what the data would be once the String has been "cut up"?
You should be able to achieve what you want using Left/Mid/Right string functions.
mattpfc's Avatar
Junior Member with 6 posts.
 
Join Date: Jul 2005
05-Jul-2005, 12:13 PM #3
The basic construct I have so far is the ability to read each line of the text file sequentially, simpple stuff so far.

What I am after is the ability to read each row and search for a certain string, then extract the section I require.

So in this instance

Code:
nodeP1R2.setFrom("SJP_8340_POInv_Input");
the only section of the string I am interested in is:

Code:
SJP_8340_POInv_Input
the program must assign this as a setFrom variable type, as I will be doing further work with it later on.


Hope this makes a bit more sence, if not i'll try again
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,554 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
05-Jul-2005, 06:21 PM #4
Try adding
Dim a as string
a = nodeP1R2.setFrom("SJP_8340_POInv_Input")
msgbox a
that should give a message box with SJP_8340_POInv_Input in it.
If you wanted just the "SJP then it would be
a = left(nodeP1R2.setFrom("SJP_8340_POInv_Input"),3)
etc
jiml8's Avatar
Senior Member with 1,514 posts.
 
Join Date: Jul 2005
Experience: I've been at this for too long.
06-Jul-2005, 12:37 AM #5
The InStr function is what you want.
http://www.w3schools.com/vbscript/func_instr.asp
CtrlAltDestr's Avatar
Junior Member with 16 posts.
 
Join Date: Sep 2004
Experience: Intermediate VB Programmer
09-Jul-2005, 02:45 AM #6
()
Use InStr() to find the location of the 2 parenthesies (or the 2 quotation marks), and use Mid() to steal the text between them.

Like this... (Assume Testcode is your string... don't forget that you can't paste the Java code directly into the compiler because the " character will confuse things, so use Chr(34) or input from the text file)

Dim X As Byte
Dim Result As String

X = InStr(Testcode, "(")
Result = Mid(Testcode, X, InStr(Testcode, ")") - X)
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:31 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.