Which format statement should be used when you want to


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)

Request for Solution File

Ask an Expert for Answer!!
Visual Basic Programming: Which format statement should be used when you want to
Reference No:- TGS01009247

Expected delivery within 24 Hours