Handling Fractions - Set Up A Bit Of Code That Would Convert The Fractions To Decimal?

May 31, 2010

As a part time CAD drafter I commonly have to do scale conversions from many different scales.I am writing a scale converter that will allow me to enter the source scale (eg. 1/4" = 1'). Then it will provide an area to enter another number, like 3/4", and then produce that number in inches. In the case of 3/4" it would equal 36" or 3 feet. For now it would be fine if only gave me the answer in inches.How would I handle all the necessary fractions? Would I have to set up a bit of code that would convert the fractions to decimal?

View 30 Replies


ADVERTISEMENT

Improper Fractions To Proper Fractions?

Oct 13, 2009

Public Class Form1
Dim intResNum, intResDenom As Integer
Private Sub btnMult_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMult.Click

[Code].....

View 3 Replies

Combobox - .net Cascading ComboBoxes Connected To DataSet From Access - Changing Units And Decimal To Fractions?

Oct 2, 2011

I have a DataSet with a DataTable that has several numeric columns of Data. The numeric data is composed of distances given in U.S. Standard units. I currently have my ComboBoxes set up and working, but I need to expand on what I currently have in two ways.I need to be able to convert the Decimal numbers in my data column being displayed to Fractions, is there a way to do this and maintain databinding? In this case its the Display Member of the data source...I need to be able to display my drop down options in different sets of units... I've written Unit Conversion classes to help take care of this, but I don't know if I can somehow do this as well and maintain databinding? I'd like to convert the units on the display members as well...

Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Select Case ComboBox1.SelectedItem

[code]....

What is the best approach for using ComboBoxes when dealing with issues such as displaying fractions and units...

View 1 Replies

Dealing With Fractions In .NET?

Jul 5, 2009

I recently found myself in a thread deling with convertions from decimal number to fractions... Being a bit too brusk and dismissing the idea at first.I have now implemented a structure based on code frm Javelia whithc can be seen in this thread.Solitare also proveided code that I eventually understood and was working.[URL]...it a step longer and developed a structure that can also implement calculating with fractions... My first try is also posted in the tread above...

The implimentation is far from perfect, as it does not deal with POW of fractions.. So if anybody has some ideas on hoe to do this with squer root and all pleas let me know and Ill update the code..

[Code]...

View 7 Replies

What Is The Best Way To Handle Fractions

Jan 19, 2012

In an upcoming project I need to keep track of some fractional data values. Due to industry standards around the products which this data describes, it is important to display the fractional value as a fraction and not as a decimal; yet for purposes of sorting and filtering the data values, the decimal value of the fraction should be known.

The obvious solution since the problem describes data is to store the value as both a string-fraction and as a decimal-value. This works fine, but it does leave a disconnect between the two values, when in fact, they represent the same data.Assuming that this project will also include a strongly typed object model, which will likely drive a EF4 Code-First database, I think that the best solution involves creating a custom fraction type which can encapsulate the string and decimal values.

After thinking on the problem and some experimentation, I've come up with the following structure to meet this need, however, I'm not certain that it is the all-around "best" implemenation.Obviously "best" is a subjective term, but in general the type should be well-rounded for as many uses as possible... idealy as generic as the Decimal type it enhances. Can anyone spot any flaws or drawbacks with this implementation? I'm still not sure about the numerator and denominator fields... whether they should be readonly or priviate or what...

Here is the code:

Imports System.Runtime.Serialization
Imports System.Text.RegularExpressions
''' <summary>

[code].....

View 1 Replies

VS 2008 How To Knock Off Fractions Of MB

Apr 7, 2010

[code]Where my code tells me the omount of memory how can i knock off the fractions of MB? using As Integer wont compile.

View 5 Replies

Include An Enum Of Fractions In An Application?

Mar 13, 2010

I wanted to include an Enum of fractions in an application.

Enum fractions
1/8
1/4
3/8
1/2
End Enum

This produces a 'Statement cannot appear within an Enum body" Error.

Is there a way to make this Enum work?

View 9 Replies

How To Round Off And Display Fractions And Percentages In A Label.Text Field

Nov 21, 2010

I get some funny display errors when I attempt to pop a fraction into a text label.[code]Do I get 33.3% here? No, but I get 33.333333333333 - etc - depending on how big my label field is Plus I also get an error message trying to add the % sign at the end.how to round off and display fractions and percentages in a Label.Text field?

View 2 Replies

VS 2005 - Handling Decimal Type Columns In SQL Server

Mar 17, 2009

Decimal type columns have Precision and Scale where the length of the integral part of the decimal would be Precision - Scale, if the Precision is 4 and the Scale is 2 then the integral part can only contain 2 digits (4-2). As such I will probably need a control that I could set how much it should accept on its integral part. In that regard I am not sure which control is best for such cases, I could try to make a usercontrol that will handle that but is there any other control out there that I could utilize for this purpose, intrinsic to .Net or a custom control out there? I could also just validate the data keyed-in but the above solution seem to be more user-friendly. Curiously, when databinding such Decimal type columns, how is it handled when the specified integral part exceeds the allowable size (Precision minus Scale)?

View 1 Replies

Convert A Decimal ( Decimal Place Holder = Dot) To A Decimal (decimal Place Holder =comma)?

Dec 20, 2010

how do you convert a decimal ( decimal place holder = dot) to a decimal (decimal place holder =comma)?

View 6 Replies

Convert BCD To Decimal?

Dec 7, 2009

I am trying to convert information stored in a file to a decimal (or ASCII) format, then write the contents of that file to a new file.

What I have is a list of files that are generated from a cash register. The documentation that was provided to me says that this particular file I am trying to work with has a length of 6, a width of 6, and that it's BCD type.

I've done quite a few google searches and can't seem to find a good solution. I know BCD numbers should be stored as 0000 format. But the problem I'm getting is when I read each part of the file (using my sr.read) I'm getting full numbers..and I am expecting the 0000 format. I'll get a 0, 0, 0, and then all of the sudden I"ll get a number that's 65,000..then I'll get a 34...and there doesn't seem to be any

I'm sure I'm doing something incorrect here, my knowledge of reading HEX, BCD, etc. is very minimal. I'm guessing it has to do with using a filestream, so I can use the fs.ReadByte() method..but when I tried that my program was literally chugging along for several minutes with no sign of ending.[code]...

View 11 Replies

Easier To Convert C# Asynchronous Socket Code Into .net Than Convert .net Code To C#?

Dec 8, 2009

my project was intially mandated to be done in c#.however a large contributor to the project wrote much of the business logic, which he knows well, in vb.net.How difficult would it be to convert the following c# code into vb.net.

[Code]...

View 5 Replies

Convert A Decimal Into A Percentage In Vb?

Feb 1, 2010

How do you convert a decimal into a percentage in visual basic? I have the code to get the problem but I need to move the decimal over two places.

View 8 Replies

Convert A Double X To A Decimal Y?

Oct 5, 2011

Let's say I want to convert a Double x to a Decimal y. There's a lot of ways to do that:

1. var y = Convert.ToDecimal(x); // Dim y = Convert.ToDecimal(x)
2. var y = new Decimal(x); // Dim y = new Decimal(x)
3. var y = (decimal)x; // Dim y = CType(x, Decimal)
4. -- no C# equivalent -- // Dim y = CDec(x)

Functionally, all of the above do the same thing (as far as I can tell). Other than personal taste and style, is there a particular reason to choose one option over the other?

EDIT: This is the IL generated by compiling the three C# options in a Release configuration:

1. call valuetype [mscorlib]System.Decimal [mscorlib]System.Convert::ToDecimal(float64)
--> which calls System.Decimal::op_Explicit(float64)

[Code]....

View 3 Replies

Convert A Whole Number Into Decimal?

Jan 14, 2012

How to convert a whole number into decimal..For example 70 to .70 because there are some price in my system that needed to be calculated by grams for example $5 per grams... I am saving the price in my database as an integer..

View 2 Replies

Convert Decimal Into Time?

Aug 18, 2010

[code]...

Very simple, I click a button and it shows the answer in the label. The answer to this is: 00:02:38 (according to excel)

But I want my Vb.net to change the decimals into the time as excel would do so. The answer vb gives me is: 0.001833786. So how can I change a decimal into a time?

View 5 Replies

Convert Decimal To DateTime?

Mar 25, 2011

how to convert Decimal To datetime?

View 4 Replies

Convert Decimal Value To Datetime?

Jun 8, 2009

I have a decimal value and i want to convert it to datetime.

Example:

Dim Excess As Decimal
Dim FixEncodedHours As Decimal
Dim OvertimeLimit As Decimal = 4D

[code]....

How can i convert the decimal result Hr_Ex to datetime?

View 2 Replies

Convert Hex To Decimal Using Program?

Mar 13, 2009

I need to convert hex to a decimal in VB.NET. Found several examples in C#, but when I tried to convert to VB.NET I was not successful. An example of a hexadecimal number that I am trying to convert is"A14152464C203230304232323020572F544947455234352E".

View 7 Replies

Convert String To Decimal?

Oct 7, 2010

How to convert string to decimal ?

input - output
45 - 45.00
45.5 - 45.50
45.51 - 45.51

View 1 Replies

Convert Text To Decimal?

May 11, 2010

The code below works until I try to convert the text box to a decimal. I think it might be because at the time of conversion the text box is empty. If thats the case, where could I do the conversion?[code]...

View 5 Replies

Convert To Two Decimal Places

Apr 28, 2007

How can I convert the Tax in the following code which is Double to a two decimal place figure[code]...

View 8 Replies

How To Convert Decimal To String

Feb 18, 2010

How can i convert decimal to string so that in can be transferred to a Label?

View 2 Replies

How To Convert Hexadecimal To Decimal

Jun 18, 2009

I currently doing a project..Using VB2005 To convert hexadecimal to decimal. Something to do with serial port..

View 14 Replies

TextBox Convert It To Decimal?

Mar 28, 2012

I have a textbox aka TXT_Weighting in which I place a value of %.

If I put in a number 0 < number < 100, it works.

However, If I put in 100, I get this error: "error converting Data Type numeric to decimal"

The Database Field has the DataType of decimal(10,2).

I have tried converting it to decimal, string, int, float in the application, but once it saves, gives the same error.

I know it is because of the database field having the type as decimal. But I cant stop the entire application, just so I can change the data type of the field.

How do I save it without getting this error? How do I control it from the application?

[Code]....

View 7 Replies

.net - String.Format Decimal With Sign Fixed Number Of Decimal Places, No Decimal Separator?

Jun 27, 2012

What is the cleanest, most readable way to String.Format a decimal with the following criteria

start with a sign symbol (+ or -)
a fixed number of fraction digits
no decimal separator
right aligned
pre-padded with "0"'s

View 3 Replies

Convert A Percentage To A Decimal Number

Feb 3, 2010

I want to know how to convert a percentage rate such as 4.5% into a decimal number in your code editor in V 2008.For example, the user input is 4.5%. Is there any function available to convert is to 0.045?

View 4 Replies

Convert A String To Decimal In Program?

May 19, 2011

What will be the easiest way to convert a string to decimal?[code]...

View 4 Replies

Convert Decimal No 57000 To 57,000 , 45750 To 45,750?

Jun 20, 2009

wanna convert decimal no 57000 to 57,000, 45750 to 45,750 just wann nos to be more readable in textbox or combobox does vb.net contain any in built feature for that ???

View 7 Replies

Convert Decimal Value To Feet Inches?

Sep 4, 2007

Convert decimal value to feet inches?

eg. convert 68.5 to 5' 8 1/2 " or 5' 8.5" ?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved