Comments

: Hay Guys,: I need help with something. I need to find a number with in a string. Now this number may be double digits and changes all the time. I want to extract the number from the string.: : Any Ideas?

You'll have to be more specific. Is it the only thing in the string? What is the range of possible values? What other "noise" characters might be there?

: Hay Guys,: I need help with something. I need to find a number with in a string. Now this number may be double digits and changes all the time. I want to extract the number from the string.: : Any Ideas?: : : Thanks,: DrKajun: :

Well, my best guess, what what you've given me (and assuming some other things) is that you want to use a variable that counts whats happening. For this example, use "c" as your counter variable. Make the changing variable add whatever to it (eg. c = c + 1) and declare it Globally. Now, finding the number within the string is the easy part. Simply do something like this:

[code] Public somethingrather (1 to c) As String [/code]

c is the always changing variable. As long as its decalred Globally in a module (Project, Add Module Command) you should have no problem. I hope I helped.

: Hay Guys,: I need help with something. I need to find a number with in a string. Now this number may be double digits and changes all the time. I want to extract the number from the string.: : Any Ideas?: : : Thanks,: DrKajun

I'm not that familiar with VB, but couldn't you loop through the string using the mid function, and apply isnumeric along the way?

[code]for i=1 to len(string) if isnumeric(mid(string, i, 1)) then ' keep track of current pos ' loop through while there's a number

cpos = i epos = cpos

while isnumeric(mid(string, epos, 1)) epos = epos + 1 wend

nstr = mid(string, spos, epos - spos)

' nstr has a number of n consecutive values if they exist exit for end ifnext[/code]

[b][red]This message was edited by MicroDot at 2004-12-21 10:5:35[/red][/b][hr]: Hay Guys,: I need help with something. I need to find a number with in a string. Now this number may be double digits and changes all the time. I want to extract the number from the string.: : Any Ideas?: : : Thanks,: DrKajun: :

Hi,Try something like this:

[code]

Private Function ExtNum(ByVal strValue As String) As Integer Dim strNum As String Dim i As Integer

On Error Resume Next

For i = 1 To Len(strValue) If IsNumeric(Mid(strValue, i, 1)) Then strNum = strNum & Mid(strValue, i, 1) Next i

: : Hay Guys,: : I need help with something. I need to find a number with in a string. Now this number may be double digits and changes all the time. I want to extract the number from the string.: : : : Any Ideas?: : You'll have to be more specific. Is it the only thing in the string? What is the range of possible values? What other "noise" characters might be there?: : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]: : [code]: $ select * from users where clue > 0: no rows returned: [/code]: :

You can do this if you have good programming logics because there are some problems which can only be solved by pure programming. The solution immediately comes in my mind is:

[code]dim i as integerdim str as stringdim formednumber as longdim tempstr as string

str = txtstring.text

for i = 1 to len(str)if isNumeric(mid$(str,i,1)) then tempstr = tempstr & mid$(str,i,1)next

: : Hay Guys,: : I need help with something. I need to find a number with in a string. Now this number may be double digits and changes all the time. I want to extract the number from the string.: : : : Any Ideas?: : You'll have to be more specific. Is it the only thing in the string? What is the range of possible values? What other "noise" characters might be there?: : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]: : [code]: $ select * from users where clue > 0: no rows returned: [/code]: :

You can do this if you have good programming logics because there are some problems which can only be solved by pure programming. The solution immediately comes in my mind is:

[code]dim i as integerdim str as stringdim formednumber as longdim tempstr as string

str = txtstring.text

for i = 1 to len(str)if isNumeric(mid$(str,i,1)) then tempstr = tempstr & mid$(str,i,1)next

: : Hay Guys,: : I need help with something. I need to find a number with in a string. Now this number may be double digits and changes all the time. I want to extract the number from the string.: : : : Any Ideas?: : : : : : Thanks,: : DrKajun: : : : : : Hi,: Try something like this:: : [code]: : Private Function ExtNum(ByVal strValue As String) As Integer: Dim strNum As Integer: Dim i As Integer: : On Error Resume Next: : For i = 1 To Len(strValue): If IsNumeric(Mid(strValue, i, 1)) Then strNum = strNum & Mid(strValue, i, 1): Next i: : ExtNum = CInt(strNum): End Function: : [/code]: : [hr]: : [b][blue]//MicroDot[/blue][/b]: :

Sorry for being so veag, I know what I want to do but it's hard to explain.

MicroDot, I think you may have give'in me a way to pull off my task. The "IsNumeric" function may allow me to put to geather some logic to find the number with in my string. Learn somthing new everyday.