What is wrong with the program segment

Assignment Help Visual Basic Programming
Reference no: EM13756085

1. Which format statement should be used when you want to output your results in tabular format with the first column 10 characters wide, the second 5, and the third 10?

a.Dim fmtStr as String = "{10}{5}{10}"
b.Dim fmtStr as String = "{0}{1}{2}"
c.Dim fmtStr as String = "{0, 10}{1, 5}{2, 10}"
d.Dim fmtStr as String = "{0, 10; 1, 5; 2, 10}"

2. What is wrong with the following program segment?
Dim name, number As String
Dim sr As IO.StreamReader = IO.File.OpenText("PHONEDIR.TXT")
name = sr.ReadLine
number = sr.ReadLine
Do While sr.Peek <> -1
If name = "Jim" Then
txtBox.Text = "Jim's number is " & number
End If
name = sr.ReadLine
number = sr.ReadLine
Loop
sr.Close()

a.number should be a numeric variable
b.If Jim's name and number are the last two entries in the file, they will not be processed by the If statement
c.The Do While loop should have been replaced by a Do...Until loop
d.There is nothing wrong with the program segment

3. Assume FILE1.TXT and FILE2.TXT are sequential files containing numeric data. Based on what you think the following segment does, what would be a good use for it?
Dim sr1 As IO.StreamReader = IO.File.OpenText("FILE1.TXT")
Dim sr2 As IO.StreamReader = IO.File.OpenText("FILE2.TXT")
Dim ans1, ans2 As String
Dim c As Integer = 0
Do While (sr1.Peek <> -1) And (sr2.Peek <> -1)
ans1 = sr1.ReadLine
ans2 = sr2.ReadLine
If ans1 <> ans2 Then
c += 1
End If
Loop
sr1.Close()
sr2.Close()
txtBox.Text = CStr(c)

Reference no: EM13756085

Questions Cloud

Purpose of preparing a trial balance : When is the trial balance prepared? What is the purpose of preparing a trial balance? What does the trial balance tell you? What does the trial balance not tell you?
Explain program segment is wrong : What is wrong with the following program segment. If Jim's name and number are the last two entries in the file, they will not be processed by the If statement
Basis of accounting : Which basis of accounting do most companies use, cash or accrual? Why? Which method is approved by GAAP? Why?
What does title medici: godfathers of renaissance suggest : What does the title The Medici: Godfathers of the Renaissance suggest about the series and the family?
What is wrong with the program segment : Which format statement should be used when you want to output your results in tabular format with the first column 10 characters wide, the second 5, and the third 10
Different users of accounting information : Who are the different users of accounting information? What are the differences between managerial and financial accounting? What is the role of the CPA and how does it differ from other accountants?
Why a king do something that he really did not want to do : Why would a king do something that he really did not want to do?
Information presented in financial statements : What types of information is provided to managers in your department and how do managers in your organization use information presented in financial statements?
Explain the significance of papyrus to the ancient egyptians : Explain the significance of papyrus to the ancient Egyptians.

Reviews

Write a Review

Visual Basic Programming Questions & Answers

  Shows diagram of holes and angle of inclination

Estimate with your designing excel visual basic software that shows diagram of holes and angle of inclination

  Write a program, and store it in a file called

Write a program, and store it in a file called Travel Expenses.xlsm, that does the following: a) It asks for a person's first name and stores it in firstName; b) it asks for a person's last name and stores it in lastName

  Write visual basic program to accept values of any unit

Write down VISUAL BASIC program to accept numeral values of any unit, sum up the total, compute the average, and then Output result with proper unit.

  Triangle of asterisks write a program that displays the

write a program that displays the following patterns separately one below the other in a textbox. use for...next loops

  Display in message label when statements are executed

What will display in MessageLabel when the following statements are executed? Assume that CountInteger = 10. MessageString = "Visual Basic is fun" IF CountInteger

  Calculates the shipping charges for a package

Program Description: This project calculates the shipping charges for a package based upon a shipping rate of $0.12 per ounce

  Design the logic for a program allows a user to enter number

Design the logic for a program that allows a user to enter 15 numbers, then displays each number and its difference from the numeric average of the numbers entered.

  A small airline has just purchased a computer for its new

a small airline has just purchased a computer for its new automated reservations system. youve been asked to develop

  Create an application that stimulates the functionality

Create an application that stimulates the functionality of the gas pump. User enters the number of gallons to purchase and clicks the desired grade (each grade is represented by a Button whose Text properties are set to Regular, Special, and Super..

  Difference between these two ways of initializing variables

What is the difference between these two ways of initializing variables - Can you explain this question and show the difference between the ways of initializing variables?

  To develop a visual basic console application

The aim of the assessment is to develop a Visual Basic console application that performs a number of mathematical functions. The mathematics package will be menu driven, i.e. a number of options will be displayed, and the user will be able to input w..

  If the sum or product of two positive integers

In C++, the largest int value is 2147483647. So, an integer larger than this cannot be stored and processed as an integer. Similarly, if the sum or product of two positive integers is greater than 2147483647, the result will be incorrect.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd