Results 1 to 7 of 7

Thread: [RESOLVED] How to change variable integer to string variable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    69

    Resolved [RESOLVED] How to change variable integer to string variable

    Hi all,

    I have a variable as a number
    Dim Number1 as integer
    Dim Charecter1 as string

    ex.

    Number1= "12345"

    after vb code will be

    charecter1 = "12345"

    which at the end i will be converting all my number variable to be as charecter varible.


    Thanks in advance for your help.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: How to change variable integer to string variable

    VB Code:
    1. Dim Number1 as integer
    2. Dim Charecter1 as string
    3. Number1= 12345
    4. charecter1 = Number1.ToString()
    You don't need double quotes when you assign a number. And there is bui;t in method ToString that will convert it to the string.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: How to change variable integer to string variable

    out of interest is it faster to use the toString method compared with the CType() method?

    Thanks

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    69

    Re: How to change variable integer to string variable

    Quote Originally Posted by Shuja Ali
    VB Code:
    1. Dim Number1 as integer
    2. Dim Charecter1 as string
    3. Number1= 12345
    4. charecter1 = Number1.ToString()
    You don't need double quotes when you assign a number. And there is bui;t in method ToString that will convert it to the string.
    Hi ,
    sorry brother is i think tostring is not for VB6
    but i did fine out cstr for vb6 but i keep getting error overflow

    VB Code:
    1. Number1 = Words(Counter)   <---- here where i get overflow error
    2.                 T1 = CStr(Number1)
    3.                 Charecter1 = T1
    4.                 MsgBox T1
    5.                 MsgBox Charecter1
    6.                 Words(Counter) = Charecter1
    7.                 'Debug.Print Words(Counter)
    8.                 T = T & " " & Words(Counter)

    thanks any way for you help brother.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    69

    Re: How to change variable integer to string variable

    Quote Originally Posted by andakali
    Hi ,
    sorry brother is i think tostring is not for VB6
    but i did fine out cstr for vb6 but i keep getting error overflow

    VB Code:
    1. Number1 = Words(Counter)   <---- here where i get overflow error
    2.                 T1 = CStr(Number1)
    3.                 Charecter1 = T1
    4.                 MsgBox T1
    5.                 MsgBox Charecter1
    6.                 Words(Counter) = Charecter1
    7.                 'Debug.Print Words(Counter)
    8.                 T = T & " " & Words(Counter)

    thanks any way for you help brother.
    the words(counter) was = 14801110073

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: How to change variable integer to string variable

    This is the vb.net forum.

    As for vb6

    VB Code:
    1. dim inumber as integer
    2. dim istring as string
    3.  
    4. inumber = 12345
    5. istring = Cstr(inumber)

    Will work.

    http://www.vbforums.com/showpost.php...1&postcount=15

    Pino

  7. #7
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: How to change variable integer to string variable

    Quote Originally Posted by andakali
    Hi ,
    sorry brother is i think tostring is not for VB6
    but i did fine out cstr for vb6 but i keep getting error overflow
    This is VB.NET Forum and I posted VB.NET code.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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