Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPPER to lower case 2

Status
Not open for further replies.

storm69

Technical User
Jan 31, 2006
26
US
I am using a home automation application that uses VB Scripts. One of the functions is Caller ID which announces the caller through MS Agent. The problem is that the phone company returns all Upper case letters in the idenity in which MS Agent spells out the name vs saying it. Is there a way to take the caller ID string and convert all the upper case letters after the first to lower case. I've been searching but not able to find anything in regards to this request. I am very new VB Scripting but trying to learn so any and all help is greatly appreciated.
 
strX = "MRMOVIE"
str1st = Left(strX, 1)
strRest = Right(strX, Len(strX) - 1)
strOutput = UCase(str1st) & LCase(strRest)
 
strX = "MRMOVIE"
strOutput = UCase(Left(strX, 1)) & LCase(Right(strX, Len(strX) - 1))
 
newVar = StrConv(oldVar, 3) ' 3=vbProperCase

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Okay, that makes sense but when I tried this it didn't work. I think that the reason is due to the fact that the string I want to change is in the middle. Using your example here is what I did but it ignored the MIDDLE string. I am also making the assumtion that my output string will now be "A"
y=left(ID,10)
w=right(ID,8)
MyString = (ID)
FirstWord = Mid(MyString, 1, 10)
LastWord = Mid(MyString, 25, 8)
MidWord = Mid(MyString, 11, 15)
strA = Midword
str1st = Left(strA, 1)
strRest = Right(strA, Len(strA) - 1)
strOutput = UCase(str1st) & LCase(strRest)

Character.Speak "Call from " & A & y
 
now why doesnt my vbscript and wsh documentation show me the StrConv function!! time to visit M$ download site, thank PHV
 
'how about something like this

strX = "mRMOVIE"
For i = 1 To Len(strX)
strTemp = Mid(strX, i, 1)
If UCase(strTemp) = strTemp Then 'we have uppercase
Exit For
End If
Next

strResult = Left(strX, i) & LCase(Right(strX, Len(strX) - i))
Msgbox strResult
 
I tried this using the above example with the following code and it still didn't work. I got the following error message: Script Error: Line 231 Wrong number of arguments or invalid property assignment: 'right'. Here is the code the way I changed it. Again, I'm not sure about the Middle word "Midword" and if I'm using it correctly as "strA".


sub Devices_CIDUpdate(ID)
y=left(ID,10)
w=right(ID,8)
MyString = (ID)
FirstWord = Mid(MyString, 1, 10)
LastWord = Mid(MyString, 25, 8)
MidWord = Mid(MyString, 11, 15)
strA = Midword
For i = 1 To Len(strA)
strTemp = Mid(strA, i, 1)
If UCase(strTemp) = strTemp Then 'we have upper case
Exit For
End If
Next
strResult = Left(strA, i) & LCase(Right(strA) - i)
 
Ooops, stupid me!!! Caught my own mistake in the strResult line. Helps if you put all of the code in there. It works like a charm, thank you so very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top