Advertisement
NelloRizzo

[VBNET] stampa le sole consonanti

Feb 14th, 2017
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.94 KB | None | 0 0
  1. Module Module1
  2.  
  3.     Sub CPrint(text As String)
  4.         Console.Write("{0} => ", text)
  5.         ' prendo tutti i caratteri di "text" uno alla volta
  6.         For Each c As Char In text
  7.             ' controlla se "c" è una vocale
  8.             ' Char.IsLetter(c) restituisce TRUE se c è
  9.             ' carattere alfabetico
  10.             If Char.IsLetter(c) AndAlso "aeiouAEIOU".IndexOf(c) = -1 Then
  11.                 ' se "c" è vocale indexof da un valore > -1
  12.                 ' quindi se -1 signfica che NON è vocale: la stampo
  13.                 Console.Write(c)
  14.             End If
  15.         Next
  16.         Console.WriteLine()
  17.     End Sub
  18.  
  19.     Sub Main()
  20.         Dim s1 As String = "Pippo"
  21.         Dim s2 As String = "PLUTO"
  22.         Dim s3 As String = "PApeRinO"
  23.         Dim s4 As String = "Paperon De' Paperoni"
  24.         CPrint(s1)
  25.         CPrint(s2)
  26.         CPrint(s3)
  27.         CPrint(s4)
  28.  
  29.         Console.ReadLine()
  30.     End Sub
  31.  
  32. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement