Solved

need help with the mid and instr functions

Posted on 2007-11-26
6
232 Views
Last Modified: 2010-04-21
I'm trying to use the mid and instr functions to pull a substring from a string like this example:

"JTTTT0645T383"TUCKER, JAMmES"9999999999999999999999999""6/27/2037"""1/1/1900""

I would like to receive this value:
JTTTT0645T383

The string ALWAYS begins w/ quotes and is ALWAYS delimited with quotes. I need the first value within the quotes returned.

please give me some ideas, thanks
0
Comment
Question by:vindog26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 250 total points
ID: 20353586
You could use Split:

Dim strSplit() As String
strSplit = Split(strTest, """")
MsgBox strSplit(1)

You could also use Mid$ and Instr as follows:

MsgBox Mid$(strTest, 2, InStr(2, strTest, """") - 2)
0
 
LVL 75
ID: 20353592
Left(YourString, Instr(1,YourString,Chr(34))-1)

try that ...

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20353597
where is this substring coming from?

0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 86

Expert Comment

by:jkr
ID: 20353604
You could just

#include <string>
using namespace std;

int pos1,pos2;

string str = // your string

pos1 = str.find('\"');
pos1 = str.find('\"', pos1 + 1);

string result = str.substr(pos1 + 1, pos 2 - pos1 - 1);
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20353727
Access
C++
Visual Basic

Which one is it ?
0
 

Author Closing Comment

by:vindog26
ID: 31411090
I actually had to go w/ this.
Mid$([val], 1, InStr(2, [val], """") - 1)
 but close enough, thankx!
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question