locked
Convert to integer as in int() RRS feed

  • Question

  • I realize how different VB has become when it comes to Windows Store apps. Many things differ so much.

    Int(numeric expression) has disappeared, and I do not see how to convert an expression from number+decimal to number only, as I would get 1 from int(1.314116) in desktop VB.

    What would I use for a Windows Store VB app ?

    I need a reference where I can see all expressions available in what appears to be a new language altogether. I tried to find that in the Microsoft reference, but all keywords I tried never go me there.

    It is a bit humiliating to find out that VB I have used for so many years has become a lot less intuitive. I ordered "Build Windows 8 apps with Microsoft Visual C# and Visual Basic Step by Step" published by Microsoft but it will take a while for it to be delivered. That is the only book I found about using VB to develop WS apps. Hope it will suffice !

    Wednesday, December 18, 2013 8:29 AM

Answers

  • The Int() and Fix() functions seem to have gone indeed, while a lot of the legacy conversion functions are still there, e.g. CInt().

    Here's an example of .NET versions of the Int and Fix functions:

    Dim newInt = System.Convert.ToInt32(4.56789) 'Returns 5
    Dim newFix = System.Convert.ToInt32(System.Math.Floor(4.56789)) 'Returns 4

    • Marked as answer by Mitchb00 Wednesday, December 18, 2013 1:53 PM
    Wednesday, December 18, 2013 9:17 AM

All replies

  • The Int() and Fix() functions seem to have gone indeed, while a lot of the legacy conversion functions are still there, e.g. CInt().

    Here's an example of .NET versions of the Int and Fix functions:

    Dim newInt = System.Convert.ToInt32(4.56789) 'Returns 5
    Dim newFix = System.Convert.ToInt32(System.Math.Floor(4.56789)) 'Returns 4

    • Marked as answer by Mitchb00 Wednesday, December 18, 2013 1:53 PM
    Wednesday, December 18, 2013 9:17 AM
  • Great ! Exactly what I needed !

    Thank you Diederik.

    Wednesday, December 18, 2013 1:53 PM