Linear Program
Input "Enter a sentence"; a$
b$ = UCase$(Left$(a$, 1))
For i = 1 To Len(a$)
c$ = Mid$(a$, i, 1)
If c$ = Space$(1) Then
b$ = b$ + UCase$(Mid$(a$, i + 1, 1))
Else
b$ = b$ + LCase$(Mid$(a$, i + 1, 1))
End If
Next
Print b$
End
====================================================
Using Sub Procedure
Cls
Input "Enter a sentence"; a$
Call titlecase(a$)
End
Sub titlecase (a$)
b$ = UCase$(Left$(a$, 1))
For i = 1 To Len(a$)
c$ = Mid$(a$, i, 1)
If c$ = Space$(1) Then
b$ = b$ + UCase$(Mid$(a$, i + 1, 1))
Else
b$ = b$ + LCase$(Mid$(a$, i + 1, 1))
End If
Next
Print b$
End Sub
====================================================
Using Function Procedure
Cls
Input "Enter a sentence"; a$
Print titlecase$(a$)
End
Function titlecase$ (a$)
b$ = UCase$(Left$(a$, 1))
For i = 1 To Len(a$)
c$ = Mid$(a$, i, 1)
If c$ = Space$(1) Then
b$ = b$ + UCase$(Mid$(a$, i + 1, 1))
Else
b$ = b$ + LCase$(Mid$(a$, i + 1, 1))
End If
Next
titlecase$ = b$
End Function
====================================================
No comments:
Post a Comment