Question

Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim...

Public Class Form1

    Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click
        Dim room As Double 'Assigns room as double
        Dim rate As Double 'Assigns rate as double
        Dim room2 As Double 'Assigns room as double
        Dim overallRate As Double 'Assigns overall as double
        Dim a As Integer 'Assign a as an integer
        For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors

            With Me
                Try

                    'Creates an error message if a number is not entered
                Catch InputBox As Exception
                    MessageBox.Show("Must be a number")


                End Try
            End With

            room = InputBox("Enter the number of rooms occupied on this floor." + a.ToString, "Data Needed")
            rate = (room / 30) * 100
            room2 = room + room2
            overallRate = (room2 / 240) * 100
            DataTxtBx.Items.Add("Floor: " + a.ToString() + "Rooms Occupied: " + room.ToString() + "" + " Occupancy Rate: " + Format(rate, "0.00") + "%")

            TotalRoomTxtBx.Text = room2.ToString
            OverallRateTxtBx.Text = Format(overallRate, "0.00") + "%"

        Next
    End Sub

    Private Sub Clear_Click(sender As Object, e As EventArgs) Handles Clear.Click
        DataTxtBx.Clear()
        TotalRoomTxtBx.Clear()
        OverallRateTxtBx.Clear()

    End Sub

    Private Sub ExitBut_Click(sender As Object, e As EventArgs) Handles ExitBut.Click
        Me.Close()
    End Sub
End Class

Error is showing up on following line

DataTxtBx.Items.Add("Floor: " + a.ToString() + "Rooms Occupied: " + room.ToString() + "" + " Occupancy Rate: " + Format(rate, "0.00") + "%")

I need all data to show up inside the DataTxBx but I am getting the error that items.add is not part of text box

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

DataTxtBx is the name given to a TextBox control for displaying results...

Error is because, TextBox control will not have Items.Add() method. Items.Add() is the method related to ListBox Control.

If you want to write data to text box, you can do like below:

DataTxtBx.Text = "Floor: " + a.ToString() + "Rooms Occupied: " + room.ToString() + "" + " Occupancy Rate: " + Format(rate, "0.00") + "%"


If you want the output to be in new lines:

Set the MultiLine property of DataTxtBx(TextBox control) to True and write the statement as below:

DataTxtBx.Text = "Floor: " + a.ToString() + Environment.NewLine + "Rooms Occupied: " + room.ToString() + Environment.NewLine + "Occupancy Rate: " + Format(rate, "0.00") + "%"

Output will be some thing like this:

Floor: 6 Rooms Occupied: 20 Occupancy Rate: 84.58% CompleteReport

Add a comment
Know the answer?
Add Answer to:
Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim...
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
  • UI: Provided Code: Public Class Form1 Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click...

    UI: Provided Code: Public Class Form1 Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub btnCalculateDueDays_Click(sender As Object, e As EventArgs) Handles btnCalculateDueDays.Click End Sub End Class tick bitwise Or operation Work with dates and times Exercise 9-1 In this exercise, you'll use the Date Time and TimeSpan st I. Open the application th ructures. n that's in the CIVB 2015iChapter 09DateHandlin a form that accepts a future date a directory. Within this project,...

  • so im trying to make a grade program and idk what im doing wrong actually if...

    so im trying to make a grade program and idk what im doing wrong actually if someone can help? (heres the lines of code i have so far if its wrong let me know how to fix them Option Strict On Option Explicit On Public Class Form1 Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim lblscore1 As Double Dim lblscore2 As Double Dim lblscore3 As Double lblscore1 = CDbl(Txtscore1.Text) lblscore2 = CDbl(Txtscore2.Text) lblscore3 = CDbl(Txtscore3.Text) lblaverage =...

  • 1_ What is the output? private void btnMethods_Click(object sender, EventArgs e) { int arg1 = 2;...

    1_ What is the output? private void btnMethods_Click(object sender, EventArgs e) { int arg1 = 2; double val = ValReturnMethod(arg1, 2.00); MessageBox.Show(val.ToString()); } private void ValReturnMethod(int val, double val2) { return val1 * val2 *25.50; } _____________________________ 2_ What is the output? private void btnMethods_Click(object sender, EventArgs e) { int arg1 = 4; double val = ValReturnMethod(ref arg1); MessageBox.Show(arg1.ToString()); } private double ValReturnMethod(ref int val1) { return val1 *25.50; } ______________________________ 3_ What is the output? private void btnMethods_Click(object sender,...

  • I am new to programming (2 weeks of playing with it) I have written code for...

    I am new to programming (2 weeks of playing with it) I have written code for a timer in Visual Studio 2013. I am wondering if someone can show me how to write code/what the code would look like in a MODULE1.vb. I was thinking that for this timer I could create MsgBox using a DO UNTIL LOOP that would pop up every 20 seconds that says "hurry up!" until 1 minute has passed. As I said I am just...

  • WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING,...

    WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING, HOW MANY QUESTIONS THEY GOT RIGHT AND WRONG. Public Class Form1 Dim r As Random = New Random Dim no1, no2 As Integer Private Sub rdbAdd_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAdd.CheckedChanged txtAnswer.Clear() txtAnswer.BackColor = Color.White no1 = randomInt() no2 = randomInt() lblOperation.Text = "+" txtNumber1.Text = no1.ToString() txtNumber2.Text = no2.ToString() End Sub Public Function randomInt() As Integer Return r.Next(20, 120) End Function...

  • I really need some help fixing a code error in Visual Basic I was wondering if...

    I really need some help fixing a code error in Visual Basic I was wondering if anyone could help fix the error that I'm about to provide in bold thanks so much! I'll also tell what the error is. Public Class MainForm Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click Me.Close() End Sub Dim img As Image = Image.FromFile("C:\Users\Pranesh\Pictures\11599264.jpg") house1PictureBox.Image = img house2PictureBox.Image = img house3PictureBox.Image = img house4PictureBox.Image = img house1PictureBox.Visible = False house2PictureBox.Visible = False house3PictureBox.Visible...

  • 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...

  • Determine the output displayed when the button is clicked on. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim...

    Determine the output displayed when the button is clicked on. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim total As Double = 0 Dim num As Integer = 1 Do While num < 5 total += num num += 1 Loop txtOutput.Text = CStr(total) End Sub

  • 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...

  • Program using visual basic.net You will create a very simple two numbers calculator with save options;...

    Program using visual basic.net You will create a very simple two numbers calculator with save options; here is the specifications for the application. Create a form divided vertically in two halves with right and left panels 1- In the left panel you will create the following control, the label or the value of the control will be in "" and the type of the control will in [] a- "First Number" [textbox] b- "Second number" [texbox] c- "Result" [textbox] -...

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