Function instr

A

AJOLSON

What would the code be to find the next character in a string

I have so far

Strtemp = instr(strin," ")
I just don’t know what to put between the " " to get the count to the next
character. No matter what the next character is.

Any help would be great.

Thanks
 
T

Tom van Stiphout

On Thu, 9 Apr 2009 20:34:04 -0700, AJOLSON

I don't understand. The next character after which one?

-Tom.
Microsoft Access MVP
 
F

fredg

What would the code be to find the next character in a string

I have so far

Strtemp = instr(strin," ")
I just don¢t know what to put between the " " to get the count to the next
character. No matter what the next character is.

Any help would be great.

Thanks

Your example is not very illuminating.
1) InStr() returns a Number value, not a string value, so StrTemp
should be a number variable, not a string variable.

2) What do you mean by 'find the next character' in a string?
What do you mean by this " No matter what the next character is"?
How can you search for a character if you do not know what it is?

To use InStr()....
InStr("YourString","r") = 4
if the count starts at the before the first "r" of the string.
InStr("YourStrings" = 7
if the count starts after the first "r".

If you meant something else, please re-think your question and post
back.
 
K

KARL DEWEY

Using this will return the position from the left that the first 'B' is to be
found in the string in the field.
Strtemp = Instr([YourField],"B")

To find a character looking from the right side use InStrRev in this way --
Strtemp = InstrRev([YourField],"B")

If string is 'Hi Bill how is your back today?' It would return 21
instead of 4.
 
A

AJOLSON

I am guessing I did not clarify vey well of what I wanted. Here is my issue.
I have a text file where the data is formatted with many blank spaces and
paragraph markers. Furthermore when the file is loaded into Access the entire
text file goes into a table with one field that is a MEMO field. The
Content of the fields looks similar to below
Thank you for listing your item with us. WE APPRECIATE YOUR BUISENSS
Below are your details
Listing Area – Somewhere USA
Check out our other specials

Remember: We offer competitive shipping an handling on all of our in
stock items
Your listing number is 2425342452343

Listing Name:
20004 Nissan

Price:
$26,000.00

With the above example I am trying to pull out the Listing Name. “2004
Nissanâ€, (Next time it might not be a 2004 Nissan. Next time it could be
anything so the 2004 is not a constant only the Listing Name: is a constant.
Also the space between the Listing Name: and the Name itself is not always
the same. So what I am doing is doing an Instr to get the # of characters to
Listing name: then adding 99 to the end of it. Below is my example
Dim IntTemp as integer
Dim strTemp as string
Dim IntTemp2 as integer
IntTemp=instr(Strin,â€Listing Name:)
strTemp = mid(Strin,intemp,100) StrTemp Leaves me with this
strTemp= “ListingName: 2004 Nissan

From this point I want to get 2004 Nissan (or whatever name may appear in
subsequent txt files) to return.
Dilemma- With the number of spaces between Listing Name: and 2004 not being
constant, And the listing name not being constant how do I get the listing
name to return with this file and subsequent files?
IntTemp2 = instr(StrTemp,???) is my question


KARL DEWEY said:
Using this will return the position from the left that the first 'B' is to be
found in the string in the field.
Strtemp = Instr([YourField],"B")

To find a character looking from the right side use InStrRev in this way --
Strtemp = InstrRev([YourField],"B")

If string is 'Hi Bill how is your back today?' It would return 21
instead of 4.



AJOLSON said:
What would the code be to find the next character in a string

I have so far

Strtemp = instr(strin," ")
I just don’t know what to put between the " " to get the count to the next
character. No matter what the next character is.

Any help would be great.

Thanks
 
K

KARL DEWEY

Try this --
Trim(Mid([YourMemo], Instr([YourMemo], "Listing Name:")))

AJOLSON said:
I am guessing I did not clarify vey well of what I wanted. Here is my issue.
I have a text file where the data is formatted with many blank spaces and
paragraph markers. Furthermore when the file is loaded into Access the entire
text file goes into a table with one field that is a MEMO field. The
Content of the fields looks similar to below
Thank you for listing your item with us. WE APPRECIATE YOUR BUISENSS
Below are your details
Listing Area – Somewhere USA
Check out our other specials

Remember: We offer competitive shipping an handling on all of our in
stock items
Your listing number is 2425342452343

Listing Name:
20004 Nissan

Price:
$26,000.00

With the above example I am trying to pull out the Listing Name. “2004
Nissanâ€, (Next time it might not be a 2004 Nissan. Next time it could be
anything so the 2004 is not a constant only the Listing Name: is a constant.
Also the space between the Listing Name: and the Name itself is not always
the same. So what I am doing is doing an Instr to get the # of characters to
Listing name: then adding 99 to the end of it. Below is my example
Dim IntTemp as integer
Dim strTemp as string
Dim IntTemp2 as integer
IntTemp=instr(Strin,â€Listing Name:)
strTemp = mid(Strin,intemp,100) StrTemp Leaves me with this
strTemp= “ListingName: 2004 Nissan

From this point I want to get 2004 Nissan (or whatever name may appear in
subsequent txt files) to return.
Dilemma- With the number of spaces between Listing Name: and 2004 not being
constant, And the listing name not being constant how do I get the listing
name to return with this file and subsequent files?
IntTemp2 = instr(StrTemp,???) is my question


KARL DEWEY said:
Using this will return the position from the left that the first 'B' is to be
found in the string in the field.
Strtemp = Instr([YourField],"B")

To find a character looking from the right side use InStrRev in this way --
Strtemp = InstrRev([YourField],"B")

If string is 'Hi Bill how is your back today?' It would return 21
instead of 4.



AJOLSON said:
What would the code be to find the next character in a string

I have so far

Strtemp = instr(strin," ")
I just don’t know what to put between the " " to get the count to the next
character. No matter what the next character is.

Any help would be great.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top