如何在VBScript中大写字符串的第一个字母

时间:2013-02-19 22:02:20

标签: vbscript

我在这里阅读了一篇非常有用的帖子How do I make the first letter of a string uppercase in JavaScript?,我很好奇使用VBScript的一个很好的解决方案。

3 个答案:

答案 0 :(得分:11)

>> s = "first word of string"
>> WScript.Echo UCase(Left(s, 1)) &  Mid(s, 2)
>>
First word of string

答案 1 :(得分:1)

str = "mY nAME iS sACHIN"

arrStr = split(str," ")

For i=0 to ubound(arrStr)

 word = lcase(trim(arrStr(i)))
 word = replace(word,mid(word,1,1),chr(asc(mid(word,1,1))-32),1,1)
 str1 = str1 & word & " "
next

msgbox trim(str1)

输出:我的名字是萨钦

答案 2 :(得分:0)

str = "mY nAME iS sACHIN"
arrStr = split(str," ")
For i=0 to ubound(arrStr)
 word = lcase(trim(arrStr(i))) 
 word = replace(word,mid(word,1,1),ucase(mid(word,1,1)),1,1)                  
 str1 = str1 & word & " "
 next
msgbox trim(str1)