Results 1 to 5 of 5

Thread: Text Conversion - Help!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Cheltenham, Glos, England
    Posts
    3

    Post

    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!!!

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    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/



  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Cheltenham, Glos, England
    Posts
    3

    Post

    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

  4. #4
    Guest

    Post

    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.

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    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
  •  



Click Here to Expand Forum to Full Width