|
-
Jun 26th, 2007, 05:27 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Get a string of unknown lenght ?
I have a string similar in form to this “12345 RTYUICK 4566/45679/23456789/2344/677”
But the real one will be different each time my runs, what I want to do is get the part of the string between the first two “/” do some calculations on it and put it back. Now in the example above “/45679/” the bit I need is the “45679” but in my app this could be “/1/” or up to “/100000000/”
So I need to say something like goto the first “/” and grab all there is until the next “/”
Is this possible? If so how?
-
Jun 26th, 2007, 05:31 AM
#2
Re: Get a string of unknown lenght ?
Dim strRet() As String
strRet = Split(your_string, "/")
If Ubound(strRet) > 1 Then Debug.Print = strRet(1)
-
Jun 26th, 2007, 05:36 AM
#3
Re: Get a string of unknown lenght ?
Another method
Code:
Private Sub Command1_Click()
Dim sYourstring As String
Dim nCutstr As String
Dim stringtoappend As String
Dim sFinalstr As String
sYourstring = "12345 RTYUICK 4566/45679/23456789/2344/677"
stringtoappend = "011111111"
Dim ipos1 As Integer
Dim ipos2 As Integer
ipos1 = InStr(1, sYourstring, "/")
ipos2 = InStr(ipos1 + 1, sYourstring, "/")
nCutstr = Mid(sYourstring, ipos1 + 1, (ipos2 - ipos1) - 1)
sFinalstr = Left(sYourstring, ipos1) & stringtoappend & Mid(sYourstring, ipos2, Len(sYourstring))
End Sub
Please mark you thread resolved using the Thread Tools as shown
-
Jun 26th, 2007, 05:39 AM
#4
Thread Starter
Fanatic Member
Re: Get a string of unknown lenght ?
Many thanks
-
Jun 26th, 2007, 05:51 AM
#5
Re: [RESOLVED] Get a string of unknown lenght ?
Addendum, to update then rebuild
strRet(1) = new_string
Debug.Print Join(strRet, "/")
-
Jun 26th, 2007, 06:01 AM
#6
Re: [RESOLVED] Get a string of unknown lenght ?
Nice method Leinard
Please mark you thread resolved using the Thread Tools as shown
-
Jun 26th, 2007, 08:40 AM
#7
Thread Starter
Fanatic Member
Re: [RESOLVED] Get a string of unknown lenght ?
-
Jun 26th, 2007, 04:18 PM
#8
Re: [RESOLVED] Get a string of unknown lenght ?
Use leinad31's code, then you just need strRet(3) (the 4th one, starting at 0). Just to be sure, you might also want to change If Ubound(strRet) > 1 to If Ubound(strRet) > 3
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jun 26th, 2007, 04:41 PM
#9
Lively Member
Re: [RESOLVED] Get a string of unknown lenght ?
y dont u just reference the value as an array like it setup?
strRet(0), strRet(1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|