Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dictionary Builder Part 1 Getting Started.

Similar presentations


Presentation on theme: "Dictionary Builder Part 1 Getting Started."— Presentation transcript:

1 Dictionary Builder Part 1 Getting Started

2 Step 1 – build the Form Controls: grpInput btnOpenDictionary lstWords
btnExtractWords txtNewWord btnAddWord btnOpenDictionary lstWords btnSave btnExit + and assorted labels

3 Which control will provide the easiest place to start?
Step 2 – start easy Which control will provide the easiest place to start?

4 Which control will provide the easiest place to start? btnAddWord.
Step 2 – start easy Which control will provide the easiest place to start? btnAddWord.

5 Step 2 – btnAddWord What does it do?

6 Step 2 – btnAddWord What does it do?
It moves a word from the textBox to the listBox.

7 Step 2 – btnAddWord What does it do? How?
It moves a word from the textBox to the listBox. How?

8 Step 2 – btnAddWord What does it do? How?
It moves a word from the textBox to the listBox. How? if there's something in the textBox

9 Step 2 – btnAddWord What does it do? How?
It moves a word from the textBox to the listBox. How? if there's something in the textBox copy it to the listBox

10 Step 2 – btnAddWord What does it do? How? What else should be done?
It moves a word from the textBox to the listBox. How? if there's something in the textBox copy it to the listBox What else should be done?

11 Step 2 – btnAddWord What does it do? How?
It moves a word from the textBox to the listBox. How? if there's something in the textBox copy it to the listBox set the focus back in the textBox

12 Step 2 – btnAddWord What does it do? How?
It moves a word from the textBox to the listBox. How? if there's something in the textBox copy it to the listBox set the focus back in the textBox clear the textBox

13 BUT not everything should go into the listBox

14 BUT not everything should go into the listBox
What conditions should be imposed on the text strings entered by the User?

15 BUT not everything should go into the listBox
We need to deal with “words” that: have UPPER case characters

16 BUT not everything should go into the listBox
We need to deal with “words” that: have UPPER case characters are too long

17 BUT not everything should go into the listBox
We need to deal with “words” that: have UPPER case characters are too long have non-alpha characters

18 BUT not everything should go into the listBox
We need to deal with “words” that: have UPPER case characters are too long have non-alpha characters duplicate a word in the list

19 BUT not everything should go into the listBox
We need to deal with “words” that: have UPPER case characters are too long have non-alpha characters duplicate a word in the list These tasks will be facilitated by using an identifier instead of object.property notation, and sub-programs.

20 Step 2 – btnAddWord Revisiting our pseudo code…
if there's something in the textBox copy it to the listBox set the focus back in the textBox clear the textBox

21 Step 2 – btnAddWord If txtWord.Text <> vbNullString Then End If

22 Step 2 – btnAddWord If txtWord.Text <> vbNullString Then Dim newWord = LCase(txtWord.Text) lstWords.Items.Add(newWord) End If

23 Step 2 – btnAddWord If txtWord.Text <> vbNullString Then Dim newWord = LCase(txtWord.Text) lstWords.Items.Add(newWord) txtWord.Focus() End If

24 Step 2 – btnAddWord If txtWord.Text <> vbNullString Then Dim newWord = LCase(txtWord.Text) lstWords.Items.Add(newWord) txtWord.Focus() txtWord.Clear() End If

25 Step 2 – btnAddWord If txtWord.Text <> vbNullString Then Dim newWord = LCase(txtWord.Text) If Len(newWord) <= 11 Then lstWords.Items.Add(newWord) txtWord.Focus() txtWord.Clear() End If

26 Step 2 – btnAddWord If txtWord.Text <> vbNullString Then Dim newWord = LCase(txtWord.Text) If Len(newWord) <= 11 Then lstWords.Items.Add(newWord) txtWord.Focus() txtWord.Clear() Else txtWord.SelectAll() End If

27 Step 2 – btnAddWord If txtWord.Text <> vbNullString Then Dim newWord = LCase(txtWord.Text) If Len(newWord) <= 11 And isWord(newWord) Then lstWords.Items.Add(newWord) txtWord.Focus() txtWord.Clear() Else txtWord.SelectAll() End If

28 Step 2.1 – isWord() Private Function isWord() End Function

29 Step 2.1 – isWord() Private Function isWord(ByVal t As String) As Boolean End Function

30 Step 2.1 – isWord() Private Function isWord(ByVal t As String) As Boolean Return ??? End Function

31 Step 2.1 – isWord() Private Function isWord(ByVal t As String) As Boolean Return flag End Function

32 Step 2.1 – isWord() Private Function isWord(ByVal t As String As Boolean Dim flag = True Return flag End Function

33 Step 2.1 – isWord() Private Function isWord(ByVal t As String) As Boolean Dim flag = True Dim c As Integer For c = 1 To Len(t) ˈ under some condition flag = False Next Return flag End Function

34 Step 2.1 – isWord() Private Function isWord(ByVal t As String) As Boolean Dim flag = True Dim c As Integer For c = 1 To Len(t) Dim thisC = Mid(t, c, 1) If thisC < "a" Or thisC > "z" Then flag = False End If Next Return flag End Function

35 Step 2.1 – isWord() Private Function isWord(ByVal t As String) As Boolean Dim flag = True Dim c As Integer For c = 1 To Len(t) Dim thisC = Mid(t, c, 1) If thisC < "a" Or thisC > "z" Then flag = False Exit For End If Next Return flag End Function

36 Step 2.2 - isUnique() End Function
Private Function isUnique(ByVal t As String) As Boolean End Function

37 Step 2.2 - isUnique() Dim flag = True Return flag End Function
Private Function isUnique(ByVal t As String) As Boolean Dim flag = True Return flag End Function

38 Step 2.2 - isUnique() Dim flag = True Dim i As Integer
Private Function isUnique(ByVal t As String) As Boolean Dim flag = True Dim i As Integer For i = 0 To lstWords.Items.Count - 1 ˈ under some condition flag = False Next Return flag End Function

39 Step 2.2 - isUnique() Dim flag = True Dim i As Integer
Private Function isUnique(ByVal t As String) As Boolean Dim flag = True Dim i As Integer For i = 0 To lstWords.Items.Count - 1 If t = lstWords.Items.Item(i) Then flag = False Exit For End If Next Return flag End Function


Download ppt "Dictionary Builder Part 1 Getting Started."

Similar presentations


Ads by Google