VB6 String Handling

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

mattpfc

Thread Starter
Joined
Jul 3, 2005
Messages
6
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

Joined
Mar 8, 2005
Messages
19,895
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

Thread Starter
Joined
Jul 3, 2005
Messages
6
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

Joined
Mar 8, 2005
Messages
19,895
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
 
Joined
Sep 29, 2004
Messages
16
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)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top