INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Is SPLIT() the way to go for this?

Is SPLIT() the way to go for this?

(OP)
I am trying to take a string like this: 3; 8; 11; 19; 22; 27;

And remove 19; from the string and piece it back together so it then reads: 3; 8; 11; 22; 27;

I have been dinking around with using Split() to do this with mixed results and I am just curious if maybe there is a better option.

RE: Is SPLIT() the way to go for this?

If your requirement is really as simple as stated then SUBSTITUTE() would be simpler.

RE: Is SPLIT() the way to go for this?

(OP)
I considered SUBSTITUTE but the string won't always be the same. Also, I will want to use the snippet of removed data elsewhere.

RE: Is SPLIT() the way to go for this?

CODE

Dim s As String
s = "3; 8; 11; 19; 22; 27;"

s = Replace(s, " 19;", "")
Debug.Print s 

Unless there is more to your requirements that you stated in your post, and I suspect there is...
Like, how do you (or better yet: your program) know that the piece you want to deal with is 19; ?

Have fun.

---- Andy

There is a great need for a sarcasm font.

RE: Is SPLIT() the way to go for this?

> the string won't always be the same

Ok, so you need to be more explicit in your requirements, then.

RE: Is SPLIT() the way to go for this?

(OP)
I feel that I was explicit in that I said "a string like this" not "this string here".

Be that as it may, I believe I can use Andrzejek's method with an added overflow protection.

Thank you.

RE: Is SPLIT() the way to go for this?

>in that I said "a string like this"

"Like this" in what sense? The same number of items? Each item within the same numerical range as the example string? Always the 4th item that needs to be removed? Always in ascending order?

e.g is

2; 3; 16; 13; 19; 4571;

legitimate, and what are we supposed to remove from it (i.e. Andrzejek's question about how you 'know that the piece you want to deal with is 19;')?

(BTW, if it happens that you already know the item you want to remove then I'm not quite sure I understand your "Also, I will want to use the snippet of removed data elsewhere." - you already have that data ...)

Also, not quite sure why you'd considered using SUBSTITUTE(), since that is an Excel function, and not a VB5/6 function.

RE: Is SPLIT() the way to go for this?

(OP)
Then you might want to take that up with mintjulep, as he/she is the one that suggested using it.

RE: Is SPLIT() the way to go for this?

Huh?

RE: Is SPLIT() the way to go for this?

Quote (Perilous1)

I considered SUBSTITUTE but the string won't always be the same

RE: Is SPLIT() the way to go for this?

(OP)
Right.. Which was in response to:

mintjulep (TechnicalUser)24 Jul 17 18:57
If your requirement is really as simple as stated then SUBSTITUTE() would be simpler.

.. meaning I looked at SUBSTITUTE() but found it to be the wrong way to go for what I wanted to do.

RE: Is SPLIT() the way to go for this?

Fine. But that's not what you said.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close