CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Number to Text

  1. #1
    Join Date
    Sep 2001
    Location
    South Dakota
    Posts
    20

    Number to Text

    Is it possible to "trick" my app into thinking that my numeric ID is actually text? If so, how?
    Thanks


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Number to Text

    Dim x As Integer
    x = 1000
    MsgBox CStr(x) = "1000"


  3. #3
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: Number to Text

    2 Ways (Assume - 4562 is the numeric ID)

    1. USing CStr(4562) - Convert(cast) to String
    2. Using the following format : 4562 & ""

    Srinika

    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Number to Text

    Well, there are some tricks to do so, like using CStr and stuff, but if it is for using as the key of a node in a treeview (I assume this cause of your previous posts), i'm affraid to disappoint you.
    The treeview will just not take it, probably because it then doesn't if you are talking about the index (numeric) or the key (string), since both are passed as variant, which could be any.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  5. #5
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: Number to Text



    private Sub Command2_Click()
    Dim temp1, temp3, temp4 as Integer
    Dim temp5 as string

    temp1 = 123
    temp3 = 1
    temp5 = ""
    temp4 = 0

    While temp1 > 0
    temp4 = temp1 Mod 10
    temp1 = temp1 - temp4
    temp1 = temp1 / 10
    temp3 = temp3 + 1
    MsgBox (temp4)
    ' Convertir temp4 en char
    temp5 = temp5 + Chr(temp4 + 48)
    Wend
    MsgBox (StrReverse(temp5))

    End Sub




    But the compiler does it by itself ( casting ).


    Nicolas Bohemier

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

Featured