I have three lists boxes.
List1 - A list of words.
ok i want to click a buttn and it will go down every word in list1 and if it contains a capital letters it gets added to list2 if it doesn';t it gets added to list1
thanks in advance
Printable View
I have three lists boxes.
List1 - A list of words.
ok i want to click a buttn and it will go down every word in list1 and if it contains a capital letters it gets added to list2 if it doesn';t it gets added to list1
thanks in advance
Do you mean add it to List3?
You could loop thru the listbox, and compare the item to the same Ucase() item, to see if they are the same. If one has a capital letter, then they won't be.
You have List1 of words, and you want List2 to be lower case, and List3 to contain words with Capitals?
yes.
Loop through each item, and search it with a small loop.
VB Code:
For counter = 1 to Len(myWord) If Asc(Mid$(myWord, counter)) >= 65 And Asc(Mid$(myWord, counter)) <= 90 Then List2.AddItem myWord End If Next counter
or something like that.
The last post will put the uppercase ones into List2, but David's way is better..
Puts any words with upper case letters in List 3, and all lower case words in list 2.VB Code:
If LCase(myWord) = myWord Then List2.AddItem myWord Else List3.AddItem myWord End If
This should do it.
VB Code:
Option Explicit Private Sub Form_Load() Dim x As Integer For x = 0 To list1.ListCount - 1 If list1.List(x) = LCase(list1.List(x)) Then list2.AddItem list1.List(x) ' all lowercase Else list3.AddItem list1.List(x) ' mixes case End If Next x End Sub