|
-
Jul 10th, 2006, 01:42 AM
#1
Thread Starter
Fanatic Member
-
Jul 10th, 2006, 02:06 AM
#2
PowerPoster
Re: Formatting...
you might want to look more into these three:
vbUppercase
vbLowercase
vbPropercase
-
Jul 10th, 2006, 02:13 AM
#3
Re: Formatting...
VB Code:
Private Sub Form_Load()
Debug.Print SentenceCase("this is a test. is it a test? yes it is! a test.")
End Sub
Private Function SentenceCase(ByVal sText As String)
Dim b() As Byte, N As Long, bChange As Boolean
b = sText
bChange = True
For N = 0 To UBound(b) Step 2
Select Case b(N)
Case 33, 46, 58, 63 ' !.:?
bChange = True
Case 97 To 122 ' a-z
If bChange Then b(N) = b(N) - 32: bChange = False
Case 32
Case Else
bChange = False
End Select
Next N
SentenceCase = b
End Function
-
Jul 11th, 2006, 06:47 AM
#4
Thread Starter
Fanatic Member
Re: Formatting...
 Originally Posted by bushmobile
VB Code:
Private Sub Form_Load()
Debug.Print SentenceCase("this is a test. is it a test? yes it is! a test.")
End Sub
Private Function SentenceCase(ByVal sText As String)
Dim b() As Byte, N As Long, bChange As Boolean
b = sText
bChange = True
For N = 0 To UBound(b) Step 2
Select Case b(N)
Case 33, 46, 58, 63 ' !.:?
bChange = True
Case 97 To 122 ' a-z
If bChange Then b(N) = b(N) - 32: bChange = False
Case 32
Case Else
bChange = False
End Select
Next N
SentenceCase = b
End Function
Hi,
Thanks. It is pretty nice. Now what I need is: when I enter a sentence in a textbox I will click on cmdSave button. So that the sentence entered should be saved in a Sentence Case format. Where should I call this function & what should be the line to call it?
Call SentenceCase ....> when I am using this line in cmdSave button's code, getting an error "argument not optional"
I have pasted the function code on the form. And calling it in cmdSave code.
Regards,
Seema_S
-
Jul 11th, 2006, 06:51 AM
#5
Re: Formatting...
well, first off, I've missed something in my code - this function should be like this:
VB Code:
Private Function SentenceCase(ByVal sText As String) [B]As String[/B]
well how you use the function is up to you. It accepts the text you want to change and outputs the changed version.e.g.:
VB Code:
Private Sub Command1_Click()
Text1.Text = SentenceCase(Text1.Text)
End Sub
-
Jul 11th, 2006, 07:26 AM
#6
Re: Formatting...
Another way of doing that:
How to make Sentence Case
-
Jul 12th, 2006, 12:08 AM
#7
Thread Starter
Fanatic Member
Re: Formatting...
 Originally Posted by bushmobile
well, first off, I've missed something in my code - this function should be like this:
VB Code:
Private Function SentenceCase(ByVal sText As String) [B]As String[/B]
well how you use the function is up to you. It accepts the text you want to change and outputs the changed version.e.g.:
VB Code:
Private Sub Command1_Click()
Text1.Text = SentenceCase(Text1.Text)
End Sub
Thanks a lot for the help.
Regards,
Seema_S
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
|