Visual Basic Questions
puja
12.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?
Save your time - order a paper!
Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines
Order Paper Now
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}â€
37.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
38.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)
a.Compare an answer key file to a student answer file to count the questions that the student answered CORRECTLY.
b.Compare an answer key file to a student answer file to count the questions that the student answered INCORRECTLY.
c.Count the total number of lines in the two files.
d.Count the total number of items in the two files.