Advertisement
cogier

Comma quibbling

Apr 8th, 2020
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.60 KB | None | 0 0
  1. 'https://rosettacode.org/wiki/Comma_quibbling
  2. Imports System
  3. Module Program
  4.     Sub Main()
  5.         Dim sInput As String() = {"", "ABC", "ABC DEF", "ABC DEF G H"}
  6.         Dim sTemp As String
  7.  
  8.         For Each sTemp In sInput
  9.             Console.Write(sTemp & " = ")
  10.             sTemp = Replace(sTemp, " ", ",")
  11.             If InStrRev(sTemp, ",") > 0 Then
  12.                 sTemp = Mid(sTemp, 1, InStrRev(sTemp, ",") - 1) & " and " & Mid(sTemp, InStrRev(sTemp, ",") + 1)
  13.             End If
  14.             sTemp = "{" & sTemp & "}"
  15.             Console.WriteLine(sTemp)
  16.         Next
  17.  
  18.     End Sub
  19. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement