Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying a fraction in a label 1

Status
Not open for further replies.

nikka

Instructor
Mar 11, 2001
36
ZA
How can I display a fraction in a label but not as 2/3? I would like the number to be above & below the line
Nikka
monique@wsl.co.za
 
Are you only using single digit fractions ie. 7/8, 3/4

or do you also want to display multi ie. 1/14, 1/100
 
23/3 single would be interesting to

Thanks

Nikka
 
This example requires that the label has wordwrap true and is high enough for 3 lines of text
font needs to be Times New Roman also.
It takes the values from two text boxes when you click command1 and copies into label as fraction.
Hope this is something like what you need.

Private Sub Command1_Click()
Dim strNumerator As String
Dim strDenominator As String
Dim strSeparator As String
Dim intCounter As Integer
Dim strLine As String


strNumerator = txtNumerator
strDenominator = txtDenominator
strSeparator = Chr(150)

If Len(strNumerator) > Len(strDenominator) Then
For intCounter = 1 To Len(strNumerator)
strLine = strLine + strSeparator
Next intCounter
Else
For intCounter = 1 To Len(strDenominator)
strLine = strLine + strSeparator
Next intCounter
End If

lblFraction.Caption = strNumerator & vbCrLf & strLine & vbCrLf & strDenominator

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top