Какой метод я должен использовать для записи фракции, например. ½ в ярлыке с помощью VB.Net?VB.Net Как написать дробь в ярлыке?
0
A
ответ
0
Я нашел лучший вариант, который использует RichTextBox вместо использования Label. Перетащите RichTextBox в форму и введите дробь с помощью сочетания клавиш.
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,5 до 1/2 в наклейке Функция возвращает 0 1/2 Чтобы опустить 0 изменения - не возвращаются «Целый»
Вы хотите, чтобы фракции ¼, ½ и ¾? Вы хотите общий случай для любых фракций? – ClickRick