English 中文(简体)
将1.5转换成 3/2 VB 2008
原标题:convert 1.5 into 3/2 VB 2008
  • 时间:2012-05-27 15:17:13
  •  标签:
  • vb.net

我正在创建一个计算器, 我需要给一个选项, 就像CASIO计算器, 我的意思是我要将“ 1.5” 转换为“ 3/2” 或“ 2.5” 转换为“ 5/2 ”

解释:

Textbox1.Text = 50

Textbox2.Text = 4


Dividing Textbo1.Text and Textbox2.Text
Calculate...........


Textbox3.text = 12.5 (Normaly)

but i dont need "12.5" I want to Convert it into "25/2"

请朋友帮助我。

提前感谢您

最佳回答

您想要做的是奇怪的, 但这是可以实现的。 这也许不是最好的解决方案, 但是它可以帮助您- 将它转换成函数, 以便您以后可以使用它 。

To make things easier, restrict to (n) decimal place(s) e.g. 1 d.p For the example you gave above, 50/4 = 12.5

To achieve 25/2 then you ll need this calculations get the integer part = 12 get the decimap part = 0.5

get the value after(.) = 5 for 1 d.p, divider = 10, for 2 d.p divider=100, so we will use 10 so we have 5/10. You have to check if 10 is divisible by 5 until [No more?] = 1/2 then you have Your (12 x (bottom) + top) / bottom = (12x2+1)/2 = 25/2

可能还有其他的替代措施...

问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签