Say for example that I have:
Dummy = "part:section:code,code2,code3:line"
I need to get the 6 values as value1, value2, value3, value4, value5, value 6.
Dummy is retrieved from a file so I can't break it up already in 6 values.
thx
grtz
Need to get values from one line.
Use MID$
http://www.petesqbsite.com/sections/tut ... rial3.html
There are also a lot of other tutorials that cover it. Do a search.
http://www.petesqbsite.com/sections/tut ... rial3.html
There are also a lot of other tutorials that cover it. Do a search.
Well, binary would be an excellent way to go if you wanted to get each value seperatly from the file itself.
For this I'd say (keep in mind this is very general code) do something like this.
Now that is extremely general. I'm not sure about all the math. I continually manage to be off by one or more letters when it comes to this sort of thing but you sound far more competant than I so I know you'll have no problem fixing this up. Good luck.
For this I'd say (keep in mind this is very general code) do something like this.
Code: Select all
'Set CurrentPos to 1
CurrentPos = 1
'Start and infinite loop, don't worry it's not really infinit, we have an escape below
Do
'See of there is a colon in the text From the last known startint point.
CurrentPos = Instr(CurrentPos,Dummy,":")
'if there is no colon then search for a comma
If CurrentPos < 1 then
CurrentPos = Instr(CurrentPos,Dummy,",")
'If there is no comma, time to escape.
If CurrentPos < 1 then
'Exit the loop
Exit Do
Else
'If there is a comma add to the counter for the value array
counter = counter +1
'Then put the text value into the value array at index of counter
value(counter) = mid(Dummy,CurrentPos,Len(Dummy)-CurrentPos)
End if
Else
'Else if there is a colon, same as comma.
counter = counter +1
value(counter) = mid(Dummy,CurrentPos,Len(Dummy)-CurrentPos)
End if
Loop
Later days,
Matthew
May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer
Matthew
May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer
Actually, you know what? I just thought up another coding example.
That might just do the exact same thing. I don't have time to test it but hopefully it'll work.
Oh, and you know what else I just thought of? These codes will only work so long as the values are only seperated by colons and commas and don't contain any themselves. There is a way to prevent that, just it would take a lot more coding.
Actually I once wrote a program in QB that was suppose to count the number of parameters in a method call for a debugger I was working on for the RPGCode language. It was over two pages long. So whether that is what was needed, or whether that was simply me being stupid I don't know. But it worked like a dream. I could have as many parameters that I wanted. Integer or string. And the string could have all of the punctuation points it wanted. Commas and all. It was great. Oh well. Later days.
Code: Select all
Do
counter = counter + 1
If mid(Dummy,counter,1) = ":" or mid(Dummy,counter,1) = "," then
ValueIndex= ValueIndex +1
Value(ValueIndex) = mid(Dummy,counter,len(Dummy)-counter)
End if
Loop until counterm > len(Dummy)
Oh, and you know what else I just thought of? These codes will only work so long as the values are only seperated by colons and commas and don't contain any themselves. There is a way to prevent that, just it would take a lot more coding.
Actually I once wrote a program in QB that was suppose to count the number of parameters in a method call for a debugger I was working on for the RPGCode language. It was over two pages long. So whether that is what was needed, or whether that was simply me being stupid I don't know. But it worked like a dream. I could have as many parameters that I wanted. Integer or string. And the string could have all of the punctuation points it wanted. Commas and all. It was great. Oh well. Later days.
Later days,
Matthew
May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer
Matthew
May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer