Comma quibbling: Difference between revisions

Content deleted Content added
Line 3,317:
{ABC and DEF}
{ABC, DEF, G and H}</pre>
 
=={{header|VBA}}==
<lang vb>Option Explicit
 
Sub Main()
Debug.Print Quibbling("")
Debug.Print Quibbling("ABC")
Debug.Print Quibbling("ABC, DEF")
Debug.Print Quibbling("ABC, DEF, G, H")
Debug.Print Quibbling("ABC, DEF, G, H, IJKLM, NO, PQRSTUV")
End Sub
 
Private Function Quibbling(MyString As String) As String
Dim s As String, n As Integer
s = "{" & MyString & "}": n = InStrRev(s, ",")
If n > 0 Then s = Left(s, n - 1) & " and " & Right(s, Len(s) - (n + 1))
Quibbling = s
End Function</lang>
{{out}}
<pre>{}
{ABC}
{ABC and DEF}
{ABC, DEF, G and H}
{ABC, DEF, G, H, IJKLM, NO and PQRSTUV}</pre>
 
=={{header|VBScript}}==