Results 1 to 7 of 7

Thread: Integer to string [RESOLVED]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Integer to string [RESOLVED]

    I wish to convert an integer into a string. Not just a string representation ( ie "1234") but its actual byte value.
    I know its something like 1st byte + 2nd byte * 256 + 3rd byte *64k etc etc, but am trying to see if theres a .net conversion that already exists. I also need to convert it back again after.
    Same thing for longs, shorts etc etc..

    Any clues ?
    Last edited by Grimfort; Jul 21st, 2004 at 11:37 AM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    VB Code:
    1. Dim List() As Byte
    2.  
    3.   'To the byte array
    4.   List = System.BitConverter.GetBytes(1234567891011121314)
    5.  
    6.   'Back to the Int64
    7.   MsgBox(BitConverter.ToInt64(list, 0).ToString)

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    VB Code:
    1. [b]  MsgBox[/b](BitConverter.ToInt64(list, 0).ToString)

    Old Vb6 programmer ALERT!

  4. #4
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Originally posted by nemaroller
    VB Code:
    1. [b]  MsgBox(BitConverter.ToInt64(list, 0).ToString)

    Old Vb6 programmer ALERT! [/B]
    True, but even MS can't get it right, so how should we?

    Over half of the samples I've seen on MSDN (where a messagebox is used) uses MsgBox.
    The documentation for MessageBox.Show says that MessageBox is preferred, but I actually read an article once on MSDN where the encouraged using MsgBox instead.

    So what to do, what to do....
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Tis true, Im a VB6 programmer with more .net experience then most, but I still like using MsgBox especially if its just an test .

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Well, doesn't matter I guess... other than Messagebox.Show is part of the Windows.Forms library, and I think MSGBOX was the VisualBasic library....

    The only benefit from using the Forms library is Messagebox.Show("Something") would work in C#, j#, etc... whereas MsgBox("Something") would not. So maintenance and project collaboration would probably dictate use of MessageBox.

    And I was a Vb6 programmer too... and used MsgBox for weeks without realizing what this MessageBox.Show was all about

  7. #7
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Originally posted by nemaroller
    And I was a Vb6 programmer too... and used MsgBox for weeks without realizing what this MessageBox.Show was all about
    Me too...And I still use MsgBox when I'm only testing, just like you, Grimfort. It's just quicker to use. But if the message is part of the finished app I always use MessageBox.Show.

    I think it's just a matter of breaking a habit, and getting used to something new.

    And yes you are right, Nemaroller, the MsgBox IS part of the Microsoft.VisualBasic namespace.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

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