Solved

need help with the mid and instr functions

Posted on 2007-11-26
6
230 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dinamic report to Crosstab query 9 33
Access 2016 Query with Proper Case logic 2 32
Access join syntax when converting to T-SQL query 4 33
Signature required on a report 5 30
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

840 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