A pangram is one of those sentences like "The quick brown fox jumps over a lazy dog" which contains every letter of the English alphabet. For all I know they may exist in other languages too. They have a minor practical use: for showing off font examples. There is an art to writing a pangram which is as short as possible but still reads like a proper sentence. See here for more information and examples.
I was amusing myself trying to invent new pangrams on paper. Checking whether you haven't missed any letters is a bit of a chore. So I made a little program that does that automatically. The program also shows the number of letters in the pangram, and it has a button for saving your pangrams to a text file.
The form contains two text boxes; the top one is multiline and the second one is read-only. The code is pretty simple:
Here's the code for the form:
I hope this inspires some amusing new pangrams.Code:Public Class PangramTesterForm Private _Alphabet As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Private _Punctuation As String = " .,-:;!?'""()[]{}/" Private _Pangram As New System.Text.StringBuilder Private Sub TextBox1_TextChanged(sender As Object, e As System.EventArgs) Handles TextBox1.TextChanged Dim missingLetters As New System.Text.StringBuilder _Pangram = New System.Text.StringBuilder(TextBox1.Text.ToUpper) 'Count letters excluding punctuation: For Each ch As Char In _Punctuation _Pangram.Replace(ch, "") Next lblCountLetters.Text = "Total number of letters = " & _Pangram.Length.ToString 'Check for missing letters: For Each ch As Char In _Alphabet.ToCharArray If Not _Pangram.ToString.Contains(ch) Then missingLetters.Append(ch) missingLetters.Append(" ") End If Next TextBox2.Text = missingLetters.ToString End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'Save the pangram to a file. Using sfd As New SaveFileDialog sfd.DefaultExt = "txt" sfd.OverwritePrompt = False If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then Using sw As New IO.StreamWriter(sfd.FileName, True) sw.WriteLine(TextBox1.Text) End Using End If End Using End Sub End Class
BB




Reply With Quote