1.write a sub called GetName that asks the user to type a first name and last na
ID: 3764430 • Letter: 1
Question
1.write a sub called GetName that asks the user to type a first name and last name in an input box, which is captured in a string variablle fullName. it shoud then call a sub called ProperCase that takes a single argument, a string, and coverts this argument to proper case. For example, if the user enters the name gEORgrbusSH, the sub should returen George Bush. the GetName sub should then display the result, such as George Bush, in a message box.
2. Repeat the previous exercise, but now ask for two separate names, firstName and lastName, in two separate input boxes, and pass these two arguments to the ProperCase sub
Please give me the VBA code for question2(which is the modified version of question1)
Please Do NOT create ProperCase as a SUB as suggests, but create it as a FUNCTION
Explanation / Answer
a)
Sub Getname()
Dim Name as string
Name=Inputbox('Enter the name')
ProperCase(Name)
End Sub
Sub ProperCase(String name)
MsgBox(StrConv(name,vbProperCase))
End Sub
'============================================================================
b)
Sub Getname()
Dim fname as string
Dim lname as string
Dim name as String
fname=Inputbox('Enter the firstname')
lname=Inputbox('Enter the lastname')
name=ProperCase(fname,lname)
MsgBox(name)
End Sub
Function ProperCase(String fname, String lname)
Dim name as String=StrConv(fname,vbProperCase)+StrConv(fname,vbProperCase)
ProperCase=name
End Function
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.