Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stripping a string and placing values into two variables!! 1

Status
Not open for further replies.

ftpdoo

Programmer
Aug 9, 2001
202
GB
Hi all,

I have an array called (aryStr) which holds a list of tags. ie:

Seq2_Response
Seq2_UOM
Seq3_UOM

I'm trying to strip these tags to place everything to the right hand side of the under score into a string: strColumnName

Then the digit to the immediate left of the under score I wish to place into another variable: intSeqNo

Thankx,
Jonathan
 
I'm not sure if this will work, but you could try using the
Code:
Split
function. It's a new one to me, so I'm not exactly sure how it works. Would probably go something like this.
Code:
Dim MyStr(2) As String
Dim StrLen As Integer

StrLen = UBound(arystr) - LBound(arystr)
For x = 1 To StrLen
   MyStr = Split(arystr(x), "_")
   strColumnName = MyStr(2)
   intSeqNo = MyStr(1)
   'INSERT THE REST OF YOUR CODE HERE...

Next x
If the
Code:
Split
works, then the only other problem you might run into is if you're trying to save intSeqNo into a number variable. Remember, MyStr is a String array, so you might have to do some conversion. ----------------------------------------
If you are reading this, then you have read too far...

lightwarrior@hotmail.com
 
Thankx,

But its throwing up a type mismatch error at the follow line:

MyStr(x) = Split(aryStr(x), "_")


any ideas??
Jonathan
 
Just out of curiosity, what was wrong? ----------------------------------------
If you are reading this, then you have read too far... :p

lightwarrior@hotmail.com
 

I changed these 2 lines and it works 110%!! :eek:)

Dim arySplit() As String
arySplit = Split(aryStr(x), "_")

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top