In: Computer Science
In Visual Basics
6.Two String returning functions to have nice looking output for numbers/money are?
7.Where do we place a class-level variable declaration, and where is it accessible from?
8.Two forms of parameter passing:
9.FULLY define an array:
10.Show the VB code to declare an initialize an array called Ar1 of Integers to hold the value of 5, 10 and 15.
11. For Ar1above, Ar1.Count = ________ and legal index values are:_____ to ______.
12.Show the VB code to declare an initialize an array Ar2 of Integers to hold 50 zeros.
13. Now write a for loop to set Ar2 to hold the values 0, 1, 2, etc, to 49 [Do NOT hardwire a “49” into thisfor-loop but rather use an expression for the upper bound]. (Hint: 3 lines)
14.Show the VB code to declare an array Ar3 of Strings with size and content to be determined later.
15.Show the VB line needed to fill Ar3 (from above) with the contents of a text file called
“C:\VB2010\MyData.txt”.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Question 6 :
Answer :
****************************
Question 7 :
Answer :
****************************
Question 8 :
Answer :
In vb arguments can be passed by value or passed by reference.
****************************
Question 9 :
Answer :
****************************
Question 10 :
Answer :Dim Ar1 As Integer() = {5, 10, 15}
****************************
Question 11 :
Answer :
Ar1.Count=3
legal index values are: 0 to 2.because array index starts with 0.
****************************
Question 12 :
Answer : Dim Ar2 As Integer() =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,0}
****************************
Question 13 :
Answer :
For i = 0 To 49
Ar2(i) = i
Next
This For loop will fill value of i as an array element from 0 to 49
****************************
Question 14 :
Answer : Dim Ar3() As String
This code snippet will create an array of String
****************************
Question 15 :
Answer :Dim Ar3() As String = System.IO.File.ReadAllLines("C:\VB2010\MyData.txt")
Above code snippet will read all lines from the file and store it in the array
****************************
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.