|
-
Jan 17th, 2000, 07:53 PM
#1
Thread Starter
New Member
I am fairly new with VB and am having problems converting certain parts of text to upper and lower case. As I enter text into a text box I need it to convert the vowels only to upper case and everything else to stay as lower. I also need to store this in a sequential file and then clear the box ready for the next line!! Can anyone help with this?? Please!!!
-
Jan 17th, 2000, 07:59 PM
#2
Addicted Member
Use the UCase() and LCase() functions.
string = UCase(string) ' Returns a uppercase.
string = LCase(string) ' Returns a lowercase.
------------------
smalig
[email protected]
http://vbcode.webhostme.com/
-
Jan 17th, 2000, 09:30 PM
#3
Thread Starter
New Member
So how do I then specify specific characters to change to Uppercase once I have converted all of them to lower? Can I use the Ascii values? If so, how do I specify these??
Thanks,
AP
-
Jan 17th, 2000, 10:25 PM
#4
May not be the fastest way but this code works:
Code:
Private Sub Convert()
Text1.Text = LCase(Text1.Text)
Do
x = InStr(1, Text1.Text, "a", vbBinaryCompare)
If x > 1 Then Text1.Text = Mid(Text1.Text, 1, x - 1) & "A" & Mid(Text1.Text, x + 1, Len(Text1.Text) - x)
If x = 1 Then Text1.Text = "A" & Mid(Text1.Text, 2, Len(Text1.Text) - 1)
Loop Until x = 0
Do
x = InStr(1, Text1.Text, "e", vbBinaryCompare)
If x > 1 Then Text1.Text = Mid(Text1.Text, 1, x - 1) & "E" & Mid(Text1.Text, x + 1, Len(Text1.Text) - x)
If x = 1 Then Text1.Text = "E" & Mid(Text1.Text, 2, Len(Text1.Text) - 1)
Loop Until x = 0
Do
x = InStr(1, Text1.Text, "i", vbBinaryCompare)
If x > 0 And x <> 1 Then Text1.Text = Mid(Text1.Text, 1, x - 1) & "I" & Mid(Text1.Text, x + 1, Len(Text1.Text) - x)
If x = 1 Then Text1.Text = "I" & Mid(Text1.Text, 2, Len(Text1.Text) - 1)
Loop Until x = 0
Do
x = InStr(1, Text1.Text, "o", vbBinaryCompare)
If x > 1 Then Text1.Text = Mid(Text1.Text, 1, x - 1) & "O" & Mid(Text1.Text, x + 1, Len(Text1.Text) - x)
If x = 1 Then Text1.Text = "O" & Mid(Text1.Text, 2, Len(Text1.Text) - 1)
Loop Until x = 0
Do
x = InStr(1, Text1.Text, "u", vbBinaryCompare)
If x > 1 Then Text1.Text = Mid(Text1.Text, 1, x - 1) & "U" & Mid(Text1.Text, x + 1, Len(Text1.Text) - x)
If x = 1 Then Text1.Text = "U" & Mid(Text1.Text, 2, Len(Text1.Text) - 1)
Loop Until x = 0
End Sub
------------------
Boothman
There is a war out there and it is about who controls the information, it's all about the information.
-
Jan 17th, 2000, 10:51 PM
#5
Or use the KeyPress event:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case LCase(Chr$(KeyAscii))
Case "a","e","o","i","u","y"
KeyAscii = Asc(UCase(Chr$(KeyAscii)))
Case Else
KeyAscii = Asc(LCase(Chr$(KeyAscii)))
End Select
Good luck!
------------------
Joacim Andersson
[email protected]
[email protected]
www.YellowBlazer.com
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
|