Results 1 to 22 of 22

Thread: VB.NET equivalent ..

  1. #1

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437

    VB.NET equivalent ..

    What is the VB.NET Equiv. of Functions like Fix, ASC and in which library can they be found ?

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    VB Code:
    1. 'asc
    2.  Dim asciiValue As Integer = System.Text.Encoding.ASCII.GetBytes(c)(0)

  3. #3
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    the namespace is microsoft.visualbasic

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    As far as Fix.... the framework will truncate if you cast a single of (3.5) into an integer, the .5 will drop off.

    VB Code:
    1. example:
    2.  Dim total As Integer = CType(3.2!, Integer)
    Last edited by nemaroller; Jul 30th, 2004 at 01:42 PM.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by Andy
    the namespace is microsoft.visualbasic
    I think that ends up being more of a crutch than helpfull.. if one is going to make the leap to VB.NET, just do it.... don't stick one foot on one side and one on the other.... commit or not.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    i agree.. i was looking for the left function and i was like "where the hell is it" looked it up in help and it said you HAVE to fully qualify it in a form because of the forms left property (this happened in VB6 with intellisense too)

    then i realized that this functionality is built right into string objects like the substring method

  7. #7
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    i agree. I was just quoting what I found in the MSDN. Can you use those functions without importing that namespace? What ARE the equivalent .net methods?

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Do you know that there are some mathematical functions in the Math class ?

  9. #9
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    VB Code:
    1. 'Fix
    2.  
    3. Math.Ceiling '(If you pass 3.5 it will give 4)
    4. Math.Floor ' (If you pass 3.5 it will give 3)
    5.  
    6. 'both only return whole numbers
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  10. #10
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    As far as I could ever tell, Fix simply truncates the decimal fraction of a number.... I guess its easier than typing out the conversion, perhaps not in c# though... result = (int)mySingle.

  11. #11
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    Originally posted by Pirate
    Do you know that there are some mathematical functions in the Math class ?
    is THAT what the Math class does?

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Andy
    is THAT what the Math class does?
    Ofcourse , I don't know mean that basic mathematical functions (+ - / *)....

  13. #13
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    spoiledkid i hate to say this, and I am not being sarcastic at all, but in the MSDN help with .NET, if you look up those functions by name you will get the documentation on them

  14. #14

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437
    I have seen the documentation on those, they are part of Microsoft.VisualBasic namespace which gives me a feeling that this namespace is just for backward compatibility ... I do not want to use anything of VB6 so I asked if there was a equivalent in .net

  15. #15
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    yeah I have yet to find something in the Microsoft.VisualBasic namespace that there is not a .net function that does the same thing

  16. #16

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437
    Originally posted by kleinma
    yeah I have yet to find something in the Microsoft.VisualBasic namespace that there is not a .net function that does the same thing

  17. #17
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I like my car...

  18. #18

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437
    Originally posted by nemaroller
    I like my car...
    then go to chit-chat

  19. #19
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    The Big D
    Posts
    310
    The only VB6 -> .NET thing I am struggling with is the Format function. I have still not figured that one out.

    For example, If I have a value x = 9, how do I format that to be 9.00? I have been using the microsoft.visualbasic namespace but would rather just use the framework to do the formatting.

  20. #20
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Originally posted by VBGuy
    The only VB6 -> .NET thing I am struggling with is the Format function. I have still not figured that one out.

    For example, If I have a value x = 9, how do I format that to be 9.00? I have been using the microsoft.visualbasic namespace but would rather just use the framework to do the formatting.
    VB.NET uses strings to format numbers

    VB Code:
    1. Dim mystring As String
    2.         Dim mynumber As Double = 9
    3.         mystring = FormatNumber(mynumber, 2)

    gives the string 9.00
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  21. #21
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I have been using the microsoft.visualbasic namespace but would rather just use the framework to do the formatting.

    Here you go, just use an overloaded method of the ToString function:
    VB Code:
    1. Dim my9 As Single = 9.121
    2. Dim myString As String = my9.ToString("#.00"))
    3. 'gives 9.12
    4.  
    5. Dim myDouble As Double = 1234567890
    6. Dim myString As String = myDouble.ToString( "(###) ### - ####" )
    7. ' gives (123) 456 – 7890
    8.  
    9. 'or use the Format function
    10. Dim price As Double = 3.21
    11. Dim myString As String = String.Format("{0:c}", price)
    12. ' gives $3.21

    http://msdn.microsoft.com/library/de...matstrings.asp

    http://msdn.microsoft.com/library/de...matstrings.asp
    Last edited by nemaroller; Aug 2nd, 2004 at 09:52 PM.

  22. #22
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    this post or a gathering of the c#/vb.net commands that are used to convert one another would make a great sticky or FAQ.

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