Question

An application contains the Structure statement shown here. Structure MyFriend Public strName As String Public strBirthday...

An application contains the Structure statement shown here.

Structure  MyFriend 
        Public strName As String 
    Public strBirthday As String
End Structure

Create a VB.Net Windows Form application named MyFriend_YourName. Change the name property of your form to frmMain.

Add the MyFriend Structure to the public class frmMain.

Create 2 text boxes txtName and txtBirthday, and a button with the name property changed to btnExecute and the text property changed to Execute.

In the button click event, write a Dim statement that declares a five-element one-dimensional array of MyFriend variables. Name the array home.

Then write an assignment statement that assigns the value in the txtName control to the strName member contained in the last array element.

Write an assignment statement that assigns the value in the txtBirthday control to the strBirthday member contained in the last array element.

Set a breakpoint next to you’re the Dim statement of your home array. See page 829 in your text for how to set breakpoints in VB.Net or search online.

Run your form, add a name and date to the respective text boxes and click the Execute button. Execution should stop at the breakpoint. Use the Debug menu or shortcut keys to step through the code. All code should execute without error

The solution that I see is:

Public Class frmMain
Structure MyFriend
Public strName As String
Public strBirthday As String
End Structure

Private Sub btnExecute_Click(sender As Object, e As EventArgs) Handles btnExecute.Click
Dim friendArray As MyFriend
friendArray.strName = txtName.Text
friendArray.strBirthday = txtBirthday.Text
MessageBox.Show("Entered Name is " + friendArray.strName + vbNewLine + "Entered Birthday is " + friendArray.strBirthday)
End Sub
End Class

However, I do not see "In the button click event, write a Dim statement that declares a five-element one-dimensional array of MyFriend variables. Name the array home." Am I missing it or not understanding something?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Updated Code:

Public Class frmMain

    'Added structure to frmMain class
    Structure MyFriend
        Public strName As String
        Public strBirthday As String
    End Structure


    ' Execute button click event handler
    Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click

        ' Declaring a five-element one-dimensional array of MyFriend variables.
        ' Array name: home
        Dim home(5) As MyFriend

        ' Storing user entered values to last element of array
        home(4).strName = txtName.Text
        home(4).strBirthday = txtBirthday.Text

        ' Displaying stored values in message box
        MessageBox.Show("Entered Name is " + home(4).strName + vbNewLine + "Entered Birthday is " + home(4).strBirthday)

    End Sub

End Class

______________________________________________________________________________________________

Sample Run:

Form1 uh Name Anil EX Entered Name is Anil Entered Birthday is 23/06/1947 Birthday: 23/06/1947 OK Execute

Add a comment
Know the answer?
Add Answer to:
An application contains the Structure statement shown here. Structure MyFriend Public strName As String Public strBirthday...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Here is the code for the Infant class: public class Infant{ private String name; private int...

    Here is the code for the Infant class: public class Infant{ private String name; private int age; // in months public Infant(String who, int months){ name = who; age = months; } public String getName(){ return name;} public int getAge(){ return age;} public void anotherMonth() {age = age + 1;} } The code box below includes a live Infant array variable, thoseKids. You cannot see its declaration or initialization. Your job is to find out which Infant in the array...

  • Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game si...

    Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game simulates a card game where the cards a placed face down and the player flips over pairs of cards in an attempt to find matching cards.   Program Procedure Display a 4x4 grid of “face down” cards. Assign the letters A through H randomly to the cards in pairs. Allow the user to click on a card to “flip” it over and...

  • Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb...

    Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb Public Class frmNewItem Public InvItem As InvItem Private Sub frmNewItem_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.LoadComboBox() End Sub Private Sub LoadComboBox() cboSizeOrManufacturer.Items.Clear() If rdoPlant.Checked Then cboSizeOrManufacturer.Items.Add("1 gallon") cboSizeOrManufacturer.Items.Add("5 gallon") cboSizeOrManufacturer.Items.Add("15 gallon") cboSizeOrManufacturer.Items.Add("24-inch box") cboSizeOrManufacturer.Items.Add("36-inch box") Else cboSizeOrManufacturer.Items.Add("Bayer") cboSizeOrManufacturer.Items.Add("Jobe's") cboSizeOrManufacturer.Items.Add("Ortho") cboSizeOrManufacturer.Items.Add("Roundup") cboSizeOrManufacturer.Items.Add("Scotts") End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click If IsValidData() Then InvItem = New InvItem(CInt(txtItemNo.Text),...

  • Zander Inc. stores employee IDs and salaries in a sequential access file named Employees.txt. Open the...

    Zander Inc. stores employee IDs and salaries in a sequential access file named Employees.txt. Open the VB2015\Chap10\Zander Solution\Zander Solution (Zander Solution.sln) file. Open the Employees.txt file, which is contained in the project’s bin\Debug folder. The ID and salary information appear on separate lines in the file. Close the Employees.txt window. a. Define a structure named Employee. The structure should contain two member variables: a String variable to store the ID and a Double variable to store the salary. b. Declare...

  • In this exercise, you’ll add code to a form that converts the value the user enters...

    In this exercise, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: 1. Open the Conversions project. Display the code for the form, and notice the rectangular array whose rows contain the value to be displayed in the combo box, the text for the labels that identify the two text boxes, and the multiplier for the conversion as shown above. Note: An array...

  • I need to write a loop that examines the names of the cities stored in the...

    I need to write a loop that examines the names of the cities stored in the array. Write code that tests for a match Write code that, when appropriate, prints the message: Not a city in Illinois _______________________________________________________________ ' IllinoisCities.vb - This program prints a message for invalid cities in Illinois. ' Input: Interactive ' Output: Error message or nothing Option Explicit On Option Strict On Module IllinoisCities    Sub Main()       ' Declare variables.         Dim city As String                 ...

  • Visual Basic: Create an application that simulates a tic tac toe game. The form uses 9...

    Visual Basic: Create an application that simulates a tic tac toe game. The form uses 9 large labels to display the x's and o's. The application should use a two dimensional integer array to simulate the game board in memory. When the user clicks the "New Game" button the application should step throguh the array storing a random number of 0 to 1 in each element. The numer 0 represent the letter o and the number 1 reprsents the letter...

  • Question 2: Execute the following program. import java.util.Arrays; public class ArrayManipulations { public static void main(String[]...

    Question 2: Execute the following program. import java.util.Arrays; public class ArrayManipulations { public static void main(String[] args) { // sort doubleArray into ascending order char [] A = {'g', ', 'y', 'a', 'e','d' }; Arrays.sort( A); for (char value: A) System.out.printf("%2C", value); System.out.printf("\n"); char [] A Copy = new char[ 3 ]; System.arraycopy( A, 2, A Copy, 0, A Copy.length); for(char value: A Copy) System.out.printf("%2C", value); System.out.printf("\n"); int location = Arrays.binary Search(A Copy, 'y'); if(location >=0) System.out.printf("y Found at element...

  • 1) Which statement is TRUE about the subroutine MyProcedure and the statement calling MyProcedure? Call statement:...

    1) Which statement is TRUE about the subroutine MyProcedure and the statement calling MyProcedure? Call statement: MyProcedure(100.0, 1000.0, 209.53) Subroutine: Sub MyProcedure(ByVal var1 As String, ByVal var2 As Double. ByVal var3 As Double) End Sub O 10000 is a constant and cannot be used as an argument value Only variables can be used as arguments in a subroutine call statement O In the call statement, a String value is provided where a Double is expected O In the call statement,...

  • In Java. Write a GUI contact list application. The program should allow you to input names...

    In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT