如何将数字转换为百分比 [英] How to convert number to percentage
本文介绍了如何将数字转换为百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在文本框中将数字转换为40到0.4
How to convert number like 40 to 0.4 in a textbox
推荐答案
将数字除以100.
这有什么难的?
Divide the number by 100.
What's so hard about this?
只需将文本框中的数字解析为double并将其除以100:
Just parse the number in the textbox to a double and divide it by 100:
Dim value As String = textBox1.Text
Dim num As Double
If Double.TryParse(value, num) Then
Dim percentage As Double = num / 100
textBox2.Text = percentage.ToString()
Else
' cannot parse the given string to a double
End If
这篇关于如何将数字转换为百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文