Help with assessment

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Help with assessment

Post by 3liiq8z »

I am a beginner at VBA and I need your help in this assessment please
1. Write the VBA code for the following program:
a. The program asks the user for Last name, First name, and an Initial using three separate inputbox lines.
b. Use Do Loops to ensure that the first name and last name are all letters-no digits, spaces, or other characters.
c. Check that the initial is a single letter or is blank.
d. If an initial is given, ask the user in a msgbox with yes/no buttons whether the initial is a middle initial.
e. Then display a msgbox listing the user’s full name appropriately, such as “Your full name is F. Nour Mohamed”, “Your name is Nour F. Mohamed”,
or “Your name is Nour Mohamed”
f. If the user presses the cancel button the program should loop to force the user to enter something with an appropriate message.
g. Use structured programming principles we covered in class. Follow the good programming practices indicated in VBA chapter 5 where applicable.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

Welcome to Eileen's Lounge!

The purpose of a forum like this is to assist users with specific questions, not to write complete solutions for them, and certainly not to do their homework!

Please start writing the code yourself, then feel free to ask questions about specific details.
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

Please I am a beginner and don't have an idea how to start. I am blind in darkness.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

Please study your learning materials. If you don't have those, why do you have this assignment?
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

Can you help with just two points a and b ?

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

a) Here is the official documentation for the InputBox function: InputBox function.
b) And here is the documentation for the Do ... Loop construct: Do...Loop statement
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

I am totally lost. The problem is not in the materials, the problem is that beyond my mind.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

Sorry to be rude, but in that case there is no point in helping you. You'll be much happier if you choose another subject.
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

Please help me with just point a and b and then I will try to do my best in the other points. need start only.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

See the documentation for the InputBox function. It contains an example.
Then create a macro that prompts the user to enter a Last Name.
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

Is that right?
Sub Code1()
Dim lastname, firstname, initial
lastname = InputBox("Enter last name")
firstname = InputBox("Enter first name")
initial = InputBox("Enter initial")
End Sub

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

Yes, that is an excellent start.
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

How can I do this step?
Use Do Loops to ensure that the first name and last name are all letters-no digits, spaces, or other characters.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

You need several functions for this:

Len function to determine the length of (for example) the lastname variable.
Mid function to extract each of the characters of the variable
Asc function to inspect the character.

I'm sure that your study materials contain information about these functions.
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

These are the materials if you like to look
http://www.mediafire.com/file/qbozlmxm9 ... s.rar/file

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

Those look like handouts from university lectures; such handouts only provide an overview of the material that has been taught.

Here is a lot more stuff to study: VBA Tutorial
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

How can I inspect if the input is consist of letters only or not?

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with assessment

Post by HansV »

Use your favorite search engine with a phrase such as

vba check if string contains only letters

We're not here to do your homework - if we do, you won't learn anything!
Best wishes,
Hans

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

Thanks anyway.

3liiq8z
NewLounger
Posts: 15
Joined: 05 Aug 2020, 20:14

Re: Help with assessment

Post by 3liiq8z »

I have found this section
Function IsAlpha(s) As Boolean
IsAlpha = Len(s) And Not s Like "*[!a-zA-Z]*"
End Function
But don't know what to do!!!