4

我在这里阅读了一篇非常有帮助的帖子如何在 JavaScript 中将字符串的第一个字母设为大写?我很好奇使用 VBScript 的一个好的解决方案。

4

3 回答 3

11
>> s = "first word of string"
>> WScript.Echo UCase(Left(s, 1)) &  Mid(s, 2)
>>
First word of string
于 2013-02-19T22:38:39.330 回答
3
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)

输出:我的名字是萨钦

于 2016-02-01T10:13:13.553 回答
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)
于 2016-11-18T05:46:38.463 回答