The Secret of Soundex, Page 5
To test out the code, let's quickly knock together a sample project.
- Launch Visual Basic
- Create a new Standard EXE project
- Paste the Soundex algorithm behind Form1
This simple project will take the values from two Text Boxes, compare them and state whether or not their Soundex codes match.
- Add two Text Boxes, a Command Button and a Label to your Form, positioning them a little like this:
Ignore regular naming conventions for now. Go on, I dare you. Hey, you've got to have a bit of fun! We're young, innocent...
- Add this code behind your Command Button:
Private Sub Command1_Click() Text1.Tag = Soundex(Text1.Text) Text2.Tag = Soundex(Text2.Text) If Text1.Tag = Text2.Tag Then Label1.ForeColor = vbRed - 100 Label1.Caption = "The Soundex codes match!" Else Label1.ForeColor = vbBlue Label1.Caption = "The Soundex codes don't match" End IfEnd Sub
That's it! You've created your simple test application.
- Press F5 to run
To test the project, enter two values such as 'JON' and 'JOHN' and hit the Command Button. You might also want to experiment with:
- Visual, Vezual
- Richard, Ricardo
- Forrest, Forest, Forrester
- Checker, Chequer
- Sideroad, Syde-rowd
- Coronation, Carnation
0 Comments (click to add your comment)
Networking Solutions
