by Jeremiah Hughes (8 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating:
(2 Votes)

I hope I'm not the only person who wants to cringe every time I see something like "You have been online for 1 minutes." 1 minutes?? I see this kind of thing everywhere; here on VBC, even. It looks very unprofessional to me, and it's so easy to fix! That's why I listed this code as beginner level. Hopefully, vbcoders.com will implement this code and I won't have to see that I got an excellent vote from "1 users." ;-) I would like to hear any comments you have about this code. Also, please click to see my other submissions to VBC. My latest program, Music Maker is nearing the top of the Code of the Month list. If I can get a few more votes it would really help me out! :-) Thanks for looking!
'add a command button and a textbox to your form
Option Explicit
Function PluralCheck(Num, Singular As String, Plural As String) As String
Dim NumString As String
NumString = Trim(Str(Num)) & " "
If Num = 1 Then
PluralCheck = NumString & Singular
Else
PluralCheck = NumString & Plural
End If
End Function
Private Sub Command1_Click()
Dim N As Integer
N = Val(Text1.Text)
MsgBox "Cats have " & PluralCheck(N, "life", "lives")
End Sub