VB6 Help For Programming (1 Viewer)

juventino

Juventus For Life
Joined
Jun 4, 2003
Messages
385
Location
Western sydney ;)
Gender
Male
HSC
2004
Calling all, students(or teachers) that know code inside out...

Ok, Party people does anyone know how abouts to go around and do this piece of nerve wrecking curse of a project....

"To write a program that makes an analysis of unbaised English text and from it Produce a hisotgram showing the relative letter frequencies, together with a display of the actual frequency of each letter as a percentage......."

So if any of you ever done this...or stumbled across something similar, please let us know (or send us the code ;) )

An Sdd class in trouble....

P.S Have a great Christmas ;)
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
if u explain to me wtf some of the shit is i can probably help

like wat do u mean unbiased english text huh? :S.. and histogram never heard of it, wtf is letter frequancies.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
A biased text would refer to something that favours certain words/letters over others. Like an unbaised/baised coin in probability. Letter frequencies would be how many times a letter occurs in the text, etc etc

More details would be good, like what language you have to do this in, and what form the text is given to you in.
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
Originally posted by sunny
A biased text would refer to something that favours certain words/letters over others. Like an unbaised/baised coin in probability. Letter frequencies would be how many times a letter occurs in the text, etc etc

More details would be good, like what language you have to do this in, and what form the text is given to you in.

so u mean the amount of times the words occur? :S like "the" would occur more than "and" ? correct?
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Yep pretty much. A very nice way to do this is with UDTs in VB, or structs in Java or C.

Baised or unbaised...doesn't really affect anything :p
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
Originally posted by sunny
Yep pretty much. A very nice way to do this is with UDTs in VB, or structs in Java or C.

Baised or unbaised...doesn't really affect anything :p

for the letters ill just use a for loop and loop through letters, and keep it in a variable, then convert it into a percentage :D...
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
well this is something i made before in vb6 which was a sdd homework, which counts how many vowels in a inputted string, the code is simple u can probably modify this code and change it so that i can do that relative frequency of letters
 

Fosweb

I could be your Doctor...
Joined
Jun 20, 2003
Messages
594
Location
UNSW. Still.
Gender
Male
HSC
2003
Nice one: the graphing bit will be cool!
Assuming that all you want to do is count the numbers of each 'letter' in some text (ie you are not considering whether it is a capital letter or not), here's how to do it:

Each letter has an ASCII equivalent (a=97, z=122 - just use lowercase for simplicity)

You will need to go through whatever string you put into the program letter by letter, so you will need a for loop (or equivalent)

It will work like this:
Code:
For letterPosition = 1 to len(inputString)
    Get Letter
    Convert to ASCII equivalent
    Add one to the corrosponding array (each letter has an array position)
Next letterPosition
Now for this array, the way I would do it would be to:
Code:
Dim letterArray(97 to 122) as Integer
That way, you can quickly just add the ascii value into the array.

Now this code doesnt check first to make sure that the letter is in the 97-122 range... You can add that yourself.

Now for the graphing!
A histogram is a line graph, where the lines are drawn between two points.
Now you have all the points you need! (As the number corrosponding to the amount of each letter in the array is the Y-Coord, and the number corrosponding to this letter's position in the alphabet is the X-Coord.
So all you need to do is start at (0,0) in a picture box, store your current position in an xVar and yVar, then get the next coords.
You then use the Line function of the picturebox and draw a line between your current coords and the next ones...

I'll write this up simply some time today/tomorrow if you still need, but i dont want to do your project for you...
 

Fosweb

I could be your Doctor...
Joined
Jun 20, 2003
Messages
594
Location
UNSW. Still.
Gender
Male
HSC
2003
Done

Ok so its done... Couldn't help it... (VB6 by the way)

Please dont just simply copy it... There's comments all the way through for you to understand, ask about any bits you dont get.

If you need more graphing options, like zooming and colouring/filling then I can help with that later...

You can easily change things like whether you want it as a percentage or an aggregate by changing the scale values of the box and removing the percentage calculating bits... (It's all commented)

Edit: Added ability to actually view the figures of the analysis.
 
Last edited:

Ragerunner

Your friendly HSC guide
Joined
Apr 12, 2003
Messages
5,472
Location
UNSW
Gender
Male
HSC
2003
Fosweb, by the looks of it, you must have really killed the SDD exam.

High band6? :p

I was planning to learn programming these holidays, but I don't see it happening :(
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top