Hi everyone, I'm really having some trouble with vb.net homework
I want to have the program display how many letters in a string it has. (i.e. How are you has 1 h, 2 o, 1 y, etc) I also want to have the most frequently occurring letter to be 150 pixels high and the others proportional to their occurrence count relative to the maximum. It should also display in a Label the most frequent letter(s), and the least frequent letter(s) that appear in the message (a letter that doesn't appear should not be listed among the least frequent letters).
Here's an example of a typical analysis.
I've got some work done as it is though.
Public Class MessageAnalyzer
Inherits System.Windows.Forms.Form
'Frequencies of the letters of the alphabet in the textbox
Private mintFrequency(25) As Integer
Private Sub pnlDisplay_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlDisplay.Paint
'Display the alphabet at the bottom of the panel
Dim objRnd As Random = New Random
Dim intX As Integer = 5
Dim intY As Integer = 210
Dim intWidth As Integer = 20
Dim intGap As Integer = 5
For intCount As Integer = Asc("A") To Asc("Z")
Dim intHeight As Integer = objRnd.Next(10, 200)
e.Graphics.FillRectangle(Brushes.Red, intX, intY - intHeight, intWidth, intHeight)
e.Graphics.DrawString(Chr(intCount), Me.Font, Brushes.Red, intX + intGap, 220)
intX += intWidth + intGap
Next
End Sub
Private Sub txtInput_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtInput.KeyPress
If e.KeyChar = vbCr Then 'Return key
'Find the frequencies
'Iterate through the text in the textbox
Dim strInput As String = txtInput.Text.ToUpper
For intIndex As Integer = 0 To strInput.Length - 1
Dim strLetter As String = strInput.Chars(intIndex)
Console.WriteLine("character at {0} = {1}", intIndex, strLetter)
Next
'draw the bar graph
pnlDisplay.Invalidate() 'triggers a repaint
End If
End Sub
End Class
Sorry for the long post, but I'm really lost now. Any help would be nice. :)