Showing posts with label Ordinal Number in Visual Basic 6. Show all posts
Showing posts with label Ordinal Number in Visual Basic 6. Show all posts

Sunday, November 22, 2015

Ordinal Number in Visual Basic 6

A sample program that I wrote using Microsoft Visual Basic 6 to check if the given number is an ordinal  number or not. The code is very simple and easy to understand for beginners that are new in Visual Basic 6 programming.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


Public Function ordinal(Number As String) As String
    If Number = "11" Or Number = "13" Then
     ordinal = Number & "th"
    ElseIf Number = "1" Then
        ordinal = Number & "st"
    ElseIf Number = "2" Then
        ordinal = Number & "nd"
    ElseIf Number = "3" Then
        ordinal = Number & "rd"
    Else: ordinal = Number & "th"
    End If
End Function


Private Sub Command1_Click()
num = ordinal(Form1.Text1.Text)
MsgBox ("The ordinal value of " & Form1.Text1.Text & " is " _
 & num & ".")
End Sub