Help with assessment
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Help with assessment
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.
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.
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
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.
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
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
Please I am a beginner and don't have an idea how to start. I am blind in darkness.
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
Please study your learning materials. If you don't have those, why do you have this assignment?
Best wishes,
Hans
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
Can you help with just two points a and b ?
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
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
b) And here is the documentation for the Do ... Loop construct: Do...Loop statement
Best wishes,
Hans
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
I am totally lost. The problem is not in the materials, the problem is that beyond my mind.
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
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
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
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.
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
See the documentation for the InputBox function. It contains an example.
Then create a macro that prompts the user to enter a Last Name.
Then create a macro that prompts the user to enter a Last Name.
Best wishes,
Hans
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
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
Sub Code1()
Dim lastname, firstname, initial
lastname = InputBox("Enter last name")
firstname = InputBox("Enter first name")
initial = InputBox("Enter initial")
End Sub
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
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.
Use Do Loops to ensure that the first name and last name are all letters-no digits, spaces, or other characters.
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
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.
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
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
These are the materials if you like to look
http://www.mediafire.com/file/qbozlmxm9 ... s.rar/file
http://www.mediafire.com/file/qbozlmxm9 ... s.rar/file
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
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
Here is a lot more stuff to study: VBA Tutorial
Best wishes,
Hans
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
How can I inspect if the input is consist of letters only or not?
-
- Administrator
- Posts: 78467
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Help with assessment
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!
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
Hans
-
- NewLounger
- Posts: 15
- Joined: 05 Aug 2020, 20:14
Re: Help with assessment
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!!!
Function IsAlpha(s) As Boolean
IsAlpha = Len(s) And Not s Like "*[!a-zA-Z]*"
End Function
But don't know what to do!!!