Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

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?

 

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.

 

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"