Results 1 to 6 of 6

Thread: **--How to extract numeric values from a listbox--**

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Arrow

    hi again now i need to know, that how can i extract numeric values from a list box, problem is that i can use the "right" and "left" funtion but i have some thing which looks like this: "2 Cars $17, 000" in a list box how do i extract only the 17000 and not the "2". thanks again

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Is the right value alway money? (so it will always contain $?)

    Code:
    Private Sub Command1_Click()
    Static x As Integer
    Dim str As String
    For x = 0 To List1.ListCount - 1
    str = str & Right(List1.List(x), Len(List1.List(x)) - InStr(1, List1.List(x), "$", vbTextCompare)) & vbcrlf
    Next x
    End Sub
    It looks a bit complicated, I know, I can clear it up if you need.

    (you still need it for the printinf stuff?)

    [Edited by Jop on 10-09-2000 at 01:56 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    thanks again but...

    thanks again, i was able to print it before with your code, that worked beautifully but the reason i need to now this was so that i could extract the numerical values and from the listbox and then add them, well i suppose that's the next problem... after the numeric value is extracted i need to add them

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I'm sorry but add them to what?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    Addicted Member
    Join Date
    May 2000
    Posts
    247
    I think he wants only the numeric values from a sentence Jop. I think that is what he meant. I think the function you are looking for is Val.
    Mako Shark
    Great White

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I think my function only add's the money value, and that's what he wants (I think), but he wants to add it to something (dunno what )

    And I don't think the Val function is suitable for this, because it search for numbers, and stops when a character is found, so it'll stop at the 2

    <Jop is editing>
    Ow I now see he want to add the numbers:
    5 + 5 = 10

    [Edited by Jop on 10-10-2000 at 11:15 AM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width