Mid function or other?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On my form, I want to return only the middle part of a field.

For example, the data stored in the table looks like:

231-1234567-8

and I want to see only the piece that says "1234567".

I have figured out how to use the =Right and =Left to get only the prefix
and suffix, but can't figure out how to get the middle part. thanks.
 
If the format is always 3 digits in the front, 7 digits in the middle, and 1
digit in the back, then you can use the Mid function as follows: Mid
(YourValue, 5, 7)

If not, then you can use the Split Function by declaring an array and
filling it with the appropriate values:

dim arrTemp() as String

arrTemp() = Split(YourValue, "-", , vbTextCompare)

The value you want would be in: arrTemp(1)

To use the value in the field, you would need to set the control source
=arrTemp(1). You can set this in the AfterUpdate Event of the field that has
the original value.
 
just go:

strNum = "231-1234567-8"

msgbox "the middle number is " & split(strNum,"-")(1)

so,

mymiddlenumber = spit("you number","-")(1)

Will fetch out the middle number

Split() is zero based, so (0) is one....etc....
 

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

Back
Top