Solved

need help with the mid and instr functions

Posted on 2007-11-26
6
229 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
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

778 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