몇 가지 방법으로 분수를 쓸 수 있습니까? VB.Net을 사용하는 레이블에서 ½?VB.Net 레이블에 분수를 쓰는 방법?
0
A
답변
0
레이블을 사용하는 대신 RichTextBox를 사용하는 더 나은 옵션을 발견했습니다. RichTextBox를 Form으로 드래그하고 단축키를 사용하여 fraction을 입력하십시오.
0
Function GetFraction(ByVal d As Double) As String
' Get the initial denominator: 1 * (10^decimal portion length)
Dim Denom As Int32 = CInt(1 * (10^d.ToString.Split("."c)(1).Length))
' Get the initial numerator: integer portion of the number
Dim Numer As Int32 = CInt(d.ToString.Split("."c)(1))
' Use the Euclidean algorithm to find the gcd
Dim a As Int32 = Numer
Dim b As Int32 = Denom
Dim t As Int32 = 0 ' t is a value holder
' Euclidean algorithm
While b <> 0
t = b
b = a Mod b
a = t
End While
'Get whole part of the number
Dim Whole As String = d.ToString.Split("."c)(0)
' Return our answer
Return Whole & " " & (Numer/a) & "/" & (Denom/a)
End Function
label.text = GetFraction (0.5)
이 기능은 함수는 0 1/2 은 0 변화를 생략로 돌아갑니다 레이블 1/2에 0.5으로 변환됩니다 - 반환하지 않습니다 "전체"
분수 ¼, ½ 및 ¾ 만 원합니까? 분수에 대한 일반적인 경우를 원하십니까? – ClickRick