|
-
May 11th, 2005, 11:21 AM
#1
Thread Starter
Hyperactive Member
Case Help
Ok im trying to make a progam where i can load a list of words and click a buttom called sort.
I know the code for lower case and upper case.
Whats the code for Sentance Case ???? Rick, Scoot, Paul examples.
Also i want to separate lines that begin with numbers ? How would i do this.
Example
69ers
999Police
Rick
Paul
so 69ers and 999Police would go in list2 and Rick and Paul will go in list 1.
Probably quite simple but i need help.
-
May 11th, 2005, 11:37 AM
#2
Re: Case Help
Something like this might work for you:
VB Code:
Select Case Sentence
Case "Rick"
'do something
Case "Scoot"
'do something
Case "Paul"
'do something
End Select
'also use Left() to check if first character is numeric
If IsNumeric(Left(some_string_variable, 1)) Then
'string begins with number
Else
'regular string
End If
-
May 11th, 2005, 11:44 AM
#3
Thread Starter
Hyperactive Member
Re: Case Help
cool got the number thing working, ok but i wana do something like this for the sentance case, i want to take all the entries from list1 and make them sentance case and then add them to list 3.
-
May 11th, 2005, 11:46 AM
#4
Re: Case Help
 Originally Posted by Ricky1
cool got the number thing working, ok but i wana do something like this for the sentance case, i want to take all the entries from list1 and make them sentance case and then add them to list 3.
Define Sentance Case? If that just starting with a capital letter?
If it is then try this:
VB Code:
Private Function IsSentanceCase(strString As String) As Boolean
Dim intKeyCode As integer
intKeyCode = Asc(Left(strString, 1)) ' Get the keycode of the first string character.
If intKeyCode >= 65 And intKeyCode <= 90 Then
IsSentanceCase = True
Else
IsSentanceCase = False
End If
End Function
Cheers,
RyanJ
Last edited by sciguyryan; May 11th, 2005 at 11:51 AM.
-
May 11th, 2005, 11:46 AM
#5
Re: Case Help
What do you mean by "Whats the code for Sentance Case"?
-
May 11th, 2005, 11:51 AM
#6
Thread Starter
Hyperactive Member
Re: Case Help
I wana take all the words in list1 and add them to list3 in sentence case, is what i want to do.
-
May 11th, 2005, 11:52 AM
#7
Re: Case Help
Try something like this for separating words starting with numbers from those that don't.
VB Code:
Const TEST_DATA = "69ers 999Police Rick Paul"
Dim strParts() As String
Dim lngIndex As Long
strParts = Split(TEST_DATA, " ")
For lngIndex = 0 To UBound(strParts)
If IsNumeric(Left$(strParts(lngIndex), 1)) Then
lstNumbers.AddItem strParts(lngIndex)
Else
lstLetters.AddItem strParts(lngIndex)
End If
Next
-
May 11th, 2005, 11:56 AM
#8
Re: Case Help
 Originally Posted by Ricky1
I wana take all the words in list1 and add them to list3 in sentence case, is what i want to do.
In that case, try something like this:
VB Code:
Dim I As Integer
List3.Clear ' Clear the listbox
For I = 0 To List1.ListCount
List3.AddItem List1.List(I)
Next I
Cheers,
RyanJ
-
May 11th, 2005, 11:59 AM
#9
Thread Starter
Hyperactive Member
Re: Case Help
but thats just gona add them to list 3 as they are in list1. Not wot i want it to do.
-
May 11th, 2005, 12:03 PM
#10
Re: Case Help
 Originally Posted by Ricky1
but thats just gona add them to list 3 as they are in list1. Not wot i want it to do.
I was presuming you were going to reorder the List1 first. (Reorder as in do yuor sorting things.)
RyanJ
-
May 11th, 2005, 12:06 PM
#11
Thread Starter
Hyperactive Member
Re: Case Help
no i need something like this.
Code:
Dim i as Integer
Dim str As String
For i = 0 to list1.listcount - 1
str = list1.list(i)
' code to make it sentance case
list3.additem str
next i
end sub
I just can't do the hard bit.
-
May 11th, 2005, 12:14 PM
#12
Re: Case Help
I'm still unsure what you mean by "sentence case".
-
May 11th, 2005, 12:18 PM
#13
Re: Case Help
 Originally Posted by MartinLiss
I'm still unsure what you mean by "sentence case".
Same here, I have never heared of that one before either.
Cheers,
RyanJ
-
May 11th, 2005, 12:18 PM
#14
Thread Starter
Hyperactive Member
Re: Case Help
Sentance Case = 1st Letter Cap
lowercase = rick
uppercase = RICK
sentence case = Rick
-
May 11th, 2005, 12:19 PM
#15
Re: Case Help
Then what I posted should work:
VB Code:
Private Function IsSentanceCase(strString As String) As Boolean
Dim intKeyCode As integer
intKeyCode = Asc(Left(strString, 1)) ' Get the keycode of the first string character.
If intKeyCode >= 65 And intKeyCode <= 90 Then
IsSentanceCase = True
Else
IsSentanceCase = False
End If
End Function
Cheers,
RyanJ
-
May 11th, 2005, 12:27 PM
#16
Thread Starter
Hyperactive Member
Re: Case Help
yeah that tells me if it is sentence case, but i wana make it sentance case if it isn't aswel. How i do that ??
-
May 11th, 2005, 12:31 PM
#17
Re: Case Help
Quick and dirty! 
VB Code:
Dim i As Integer
Dim str As String
For i = 0 To list1.ListCount - 1
str = UCase(Left(list1.List(i), 1)) & _
Right(list1.List(i), Len(list1.List(i)) - 1)
list3.AddItem str
Next i
-
May 11th, 2005, 12:34 PM
#18
Re: Case Help
 Originally Posted by Ricky1
yeah that tells me if it is sentence case, but i wana make it sentance case if it isn't aswel. How i do that ??
Ah, right, try this:
VB Code:
Private Function UpperFirst(strString As String) As String
Dim intCharacter As Integer
Dim strSection As String
intCharacter = Asc(Left(strString, 1))
If intCharacter < 97 Or intCharacter > 122 then
UpperFirst = strString
Else
strSection = Right(strString, Len(strString) - 1)
UpperFirst = Chr(intCharacter - 32) & strSection
End if
End Function
Cheers,
RyanJ
-
May 11th, 2005, 12:38 PM
#19
Thread Starter
Hyperactive Member
Re: Case Help
lol dg you always answer my questions.
Cheers For The Help Every1 Im Getting Somewhere Now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|