Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Fractions in Visual Basic.Net

Fractions in Visual Basic.Net

Scheduled Pinned Locked Moved Visual Basic
questioncsharphelp
14 Posts 5 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Christian Graus

    What fractions in System.Math ? VB.NET has numeric types, your core need is Convert.ToDouble(), to convert the text entered into a non-whole number, and ToString, to convert back to a string to put in the label. The rest is trivial. Christian Graus - Microsoft MVP - C++

    D Offline
    D Offline
    Desi Bravo
    wrote on last edited by
    #4

    I appreciate for your time. I am an intermediate programmer, I am not an expert like you. So being trivial I really dont think so in my part. I am trying to learn this solution. I enter a numerator and denominator in the textboxes. There is no text to convert. Trying to figure out how to use the numerator and denominator in a fractional sense in a program. Don't know if i would use the abs or just something else to get the result in the label as a fraction.

    C 1 Reply Last reply
    0
    • T toxcct

      TextBoxAnswer.Text = (Double.Parse(TexteBox1.Text) / Double.Parse(TextBox2.Text)).ToString()


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      D Offline
      D Offline
      Desi Bravo
      wrote on last edited by
      #5

      I appreciate for your help, but I already know to convert a fraction to a decimal. The code is related only to fraction conversion to decimal. I would need to know how to render an answer in fraction not decimal. For instance, 5/8 + 1/8 = 6/8 reduces to 3/4. So therefore, the textbox1 will be the numerator and textbox2 will be denominator. The third textbox will return the fractional value. Or textbox3 will be the numerator and textbox4 will be the denominator and this will invoke the answer. I am having the problem of generating a code for the above instance in fractions. bravo659

      T 1 Reply Last reply
      0
      • D Desi Bravo

        I appreciate for your help, but I already know to convert a fraction to a decimal. The code is related only to fraction conversion to decimal. I would need to know how to render an answer in fraction not decimal. For instance, 5/8 + 1/8 = 6/8 reduces to 3/4. So therefore, the textbox1 will be the numerator and textbox2 will be denominator. The third textbox will return the fractional value. Or textbox3 will be the numerator and textbox4 will be the denominator and this will invoke the answer. I am having the problem of generating a code for the above instance in fractions. bravo659

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #6

        ah, but you never said you wanted to make a formal calculus... i never searched for that exactly, but looking at some math parsers here on CP should help you to achieve your goal. moreover, don't 5/8 + 1/8 make 6/8 ??? :-D anyway, nevermind, i won't repeat it :laugh:


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        D 1 Reply Last reply
        0
        • T toxcct

          ah, but you never said you wanted to make a formal calculus... i never searched for that exactly, but looking at some math parsers here on CP should help you to achieve your goal. moreover, don't 5/8 + 1/8 make 6/8 ??? :-D anyway, nevermind, i won't repeat it :laugh:


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          D Offline
          D Offline
          Desi Bravo
          wrote on last edited by
          #7

          It's only an example. In a tape measure would be 3/4 of an inch. And Yes, it would also be 6/8 but reduce it to the LCD would be 3/4. That's the only problem that I am having, using the fractional portion to render an answer in fractions. There is a site called Break Tru, and they are selling a fraction and decimal program, but can't get the code for that program. For what I want it for is for several fraction programs. Does your home have heat oil. Then you would know that the tank only reads in fractions. I created a program that will give you how much oil you have in your tank and the amount you need to refill it, and how much it will cost you, and the amount of tax and a grand total. I also added on the form a fraction to decimal converter, which is the only i can offer under that program because I don't know how to render the fraction resulting in fractions. If you know of anything or a book that I can purchase in algorithm please let me know. I am up to programing almost in calculus. LOL Thanks Bro for your help.

          T K 3 Replies Last reply
          0
          • D Desi Bravo

            It's only an example. In a tape measure would be 3/4 of an inch. And Yes, it would also be 6/8 but reduce it to the LCD would be 3/4. That's the only problem that I am having, using the fractional portion to render an answer in fractions. There is a site called Break Tru, and they are selling a fraction and decimal program, but can't get the code for that program. For what I want it for is for several fraction programs. Does your home have heat oil. Then you would know that the tank only reads in fractions. I created a program that will give you how much oil you have in your tank and the amount you need to refill it, and how much it will cost you, and the amount of tax and a grand total. I also added on the form a fraction to decimal converter, which is the only i can offer under that program because I don't know how to render the fraction resulting in fractions. If you know of anything or a book that I can purchase in algorithm please let me know. I am up to programing almost in calculus. LOL Thanks Bro for your help.

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #8

            Search CodeProject[^]


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            1 Reply Last reply
            0
            • D Desi Bravo

              It's only an example. In a tape measure would be 3/4 of an inch. And Yes, it would also be 6/8 but reduce it to the LCD would be 3/4. That's the only problem that I am having, using the fractional portion to render an answer in fractions. There is a site called Break Tru, and they are selling a fraction and decimal program, but can't get the code for that program. For what I want it for is for several fraction programs. Does your home have heat oil. Then you would know that the tank only reads in fractions. I created a program that will give you how much oil you have in your tank and the amount you need to refill it, and how much it will cost you, and the amount of tax and a grand total. I also added on the form a fraction to decimal converter, which is the only i can offer under that program because I don't know how to render the fraction resulting in fractions. If you know of anything or a book that I can purchase in algorithm please let me know. I am up to programing almost in calculus. LOL Thanks Bro for your help.

              K Offline
              K Offline
              Kevin McFarlane
              wrote on last edited by
              #9

              If you go to Jesse Liberty's site http://www.libertyassociates.com/pages/book_edit.htm[^] and download the source code for Programming C# 3rd edition then you'll find a (simplified) Fraction class that you could perhaps adapt for your purposes. It's in the Ch 6 folder. Kevin

              1 Reply Last reply
              0
              • D Desi Bravo

                It's only an example. In a tape measure would be 3/4 of an inch. And Yes, it would also be 6/8 but reduce it to the LCD would be 3/4. That's the only problem that I am having, using the fractional portion to render an answer in fractions. There is a site called Break Tru, and they are selling a fraction and decimal program, but can't get the code for that program. For what I want it for is for several fraction programs. Does your home have heat oil. Then you would know that the tank only reads in fractions. I created a program that will give you how much oil you have in your tank and the amount you need to refill it, and how much it will cost you, and the amount of tax and a grand total. I also added on the form a fraction to decimal converter, which is the only i can offer under that program because I don't know how to render the fraction resulting in fractions. If you know of anything or a book that I can purchase in algorithm please let me know. I am up to programing almost in calculus. LOL Thanks Bro for your help.

                K Offline
                K Offline
                Kevin McFarlane
                wrote on last edited by
                #10

                Re: Jesse Liberty - Programming C# - he has a VB .NET version of the same book with source code so you could download the source for that one instead. Kevin

                D 1 Reply Last reply
                0
                • D Desi Bravo

                  I am using visual basic.net only. I need some help in fractions. How can I use the fractions in system.math to create a fraction program? I will use two textboxes and a label for the answer within a form and i will be adding, subtracting, multiplying, and dividing. Can anyone assist with a sample code? :) bravo659

                  A Offline
                  A Offline
                  Anonymous
                  wrote on last edited by
                  #11

                  This sounds more like an issue with Math than it is VB .NET X| It's just a matter of making the right calculations to display the appropriate whole number.

                  D 1 Reply Last reply
                  0
                  • A Anonymous

                    This sounds more like an issue with Math than it is VB .NET X| It's just a matter of making the right calculations to display the appropriate whole number.

                    D Offline
                    D Offline
                    Desi Bravo
                    wrote on last edited by
                    #12

                    Oh no, i know how to calculate fractions without a problem, is that how do you use the textboxes to display fractions. That's the problem. I've seen it done through C#, but I tried to use it in VB.Net, and it doesn't work. So the solution is in progrmming in VB.Net. That's all. I appreciate for your feedback.

                    1 Reply Last reply
                    0
                    • K Kevin McFarlane

                      Re: Jesse Liberty - Programming C# - he has a VB .NET version of the same book with source code so you could download the source for that one instead. Kevin

                      D Offline
                      D Offline
                      Desi Bravo
                      wrote on last edited by
                      #13

                      I appreciate for your info. I'll try Jesse's book. bravo659

                      1 Reply Last reply
                      0
                      • D Desi Bravo

                        I appreciate for your time. I am an intermediate programmer, I am not an expert like you. So being trivial I really dont think so in my part. I am trying to learn this solution. I enter a numerator and denominator in the textboxes. There is no text to convert. Trying to figure out how to use the numerator and denominator in a fractional sense in a program. Don't know if i would use the abs or just something else to get the result in the label as a fraction.

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #14

                        There is nothing in the Math namespace to show fractions as fractions. You need to convert to numbers, work out a whole number part, and render it all as text yourself. Christian Graus - Microsoft MVP - C++

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups