Results 1 to 11 of 11

Thread: [RESOLVED] truncate integer in string

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Manila
    Posts
    85

    Resolved [RESOLVED] truncate integer in string

    hello, is it possible to truncate or get the value of a number in a string? i have a combobox that displays varchar values from the database for example MNG-5.

    i want to get the number 5 and maybe put it in a label or a textbox, is it possible? thanks.

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: truncate integer in string

    The String will always follow that Chars-Numbers Pattern?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Manila
    Posts
    85

    Re: truncate integer in string

    Yes it does.

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: truncate integer in string

    Will that always be the format? Will there always be a dash preceding the number? Will the number be always at the rightmost portion of string?

  5. #5
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: truncate integer in string

    Debug.Print CLng(Split(yourString, "-")(1))

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Manila
    Posts
    85

    Re: truncate integer in string

    Debug.Print? can you use that in vb6? I'm sorry i must have forgotten that i am using vb6 hehe

  7. #7
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: truncate integer in string

    Just a way to show the output. Debug.Print outputs to the IDE's immediate window. You can use MsgBox if you prefer.

  8. #8
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: truncate integer in string

    In this case you won't need CLng() since you want the result to be String Format to add it to a TextBox or Label.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Manila
    Posts
    85

    Re: truncate integer in string

    Oh. but is it possible to get the value of the integer and store it somewhere? like maybe in a label or a textbox?

  10. #10
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: truncate integer in string

    Yes, result is a string. Simply assign it like you would any other string.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Manila
    Posts
    85

    Re: truncate integer in string

    thanks.

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