Reputation: 29
How can I write my full name where the first letter is in upper-case and the rest is lower-case for example:
Michael Jonson Bech
I have this so fair:
option Explicit
Dim Name,fName
Name = Split(InputBox("what is your name"))
Dim var
For Each var In Name
'var=UCase(Left(var,1))
LCase(var)
UCase (Left(var,1))
Next
fName = Join(Name)
WScript.Echo("you name is : " & fName )
Upvotes: 1
Views: 367
Reputation: 38775
String functions like UCase do not modify the operand, but return a modified copy. For Each v gives you copies of the array's elements named v.
So you need something like this:
Option Explicit
Dim a : a = Split("mIchael jOnson bEch")
WScript.Echo Join(a)
Dim i
For i = 0 To UBound(a)
a(i) = UCase(Left(a(i), 1)) & LCase(Mid(a(i), 2))
Next
WScript.Echo Join(a)
output:
cscript 34629546.vbs mIchael jOnson bEch Michael Jonson Bech
Upvotes: 1
Reputation: 2534
This looks like VB6, in which case something like :
Dim Name as string
Name = InputBox("what is your name")
Name = StrConv(Name, vbProperCase)
Upvotes: 0