Question

In: Computer Science

For each of the following Visual Basic code snippets, identify the syntax error.   If intX >...

For each of the following Visual Basic code snippets, identify the syntax error.  

If intX > 100   lblResult.Text = "Invalid Data" End If  

Dim str As String = "Hello" Dim intLength As Integer intLength = Length(str)

If intZ < 10 Then   lblResult.Text = "Invalid Data"  

Dim str As String = "123" If str.IsNumeric Then   lblResult.Text = "It is a number." End If  

Select Case intX   Case < 0     lblResult.Text = "Value too low."   Case > 100     lblResult.Text = "Value too high."   Case Else     lblResult.Text = "Value just right." End Select

Solutions

Expert Solution

Syntax Error Detection and correction

'Syntax error detect and change --> Declare X and Z as integer
        Dim X As Integer = 0
        Dim Z As Integer = 0
        If X > 100 Then
            lblResult.Text = "Invalid Data"
        End If

        Dim str As String = "Hello"
        Dim intLength As Integer
        'Syntax error detect and change --> Length method call
        intLength = str.Length()

        If Z < 10 Then
            lblResult.Text = "Invalid Data"
        End If
        'Syntax error detect and change --> Dstr already declared so inititalize
        str = "123"
        If IsNumeric(str) Then
            lblResult.Text = "It is a number."
        End If
        'Syntax error detect and change --> Select case arrangement
        Select Case X
            Case < 0
                lblResult.Text = "Value too low."
            Case > 100
                lblResult.Text = "Value too high."
            Case Else
                lblResult.Text = "Value just right."
        End Select


Related Solutions

Question1 if possible, could anyone do with explanation For each of the following code snippets, give...
Question1 if possible, could anyone do with explanation For each of the following code snippets, give both of the following: a. Give the overall T(n) run me analysis expression for the code. b. Describe the worst case running me of the code snippet in Big‑Oh notation. 1.for (int i=0;i<n;i++) { for (int j=0;j<n/2;j++) { sum++;} } 2.void silly(int n,int x,int y) { for (int i=0;i<n/2;i++) { if (x<y) { for (int j=0;j<100*n*n;j++) { cout<< "j="<<j<<endl;}} else {cout <<"i="<<i<<endl;}}} 3.void silly(int...
This is a numerical methods question using MATLAB. Which of the following code snippets finds the...
This is a numerical methods question using MATLAB. Which of the following code snippets finds the forward difference estimate of the derivative at each of the x values. Assume x and y have been previously defined, for example as y=[10,20,25, 27.5, 30]; x = [0.3,0.5, 0.8, 0.9, 1]; (d is the derivative variable name) Although not necessarily so, there may be more than one correct answer. a) for k=1:length(y)-1 d(k)=(y(k+1)-y(k))/(x(k+1)-x(k)); end d(k+1)=NaN b) for k=1:length(y) d(k)=(y(k+1)-y(k))/(x(k+1)-x(k)); end c) d(1)=NaN; for...
Language:C++ NEEDS TO WORK IN VISUAL BASIC error on line 41 expression must have a constant...
Language:C++ NEEDS TO WORK IN VISUAL BASIC error on line 41 expression must have a constant value #include using namespace std; //function declaration void EnterRents(int*, int); void displayRents(int*, int); void selectionSort(int*, int); int sumRents(int* temp, int size) { int sum = 0; for (int i = 0; i < size; i++) { sum += *(temp + i); } return sum; } void Displaymemory(int* temp, int size) { /*int memory; memory=sizeof(temp)*size; cout< for (int i = 0; i < size; i++)...
Each of the following pairs of null and alternative hypothesis has some error. Identify the error...
Each of the following pairs of null and alternative hypothesis has some error. Identify the error and explain how to fix it. H0: The average ‘freshness’ of an edible food arrangement is at least 3 hours H1: The average ‘freshness’ of an edible food arrangement is not 3 hours H0: The average ‘freshness’ of an edible food arrangement is more than 3 hours H1: The average ‘freshness’ of an edible food arrangement is less than 3 hours H0: The average...
IDENTIFY THE ERROR SO THAT THE CODE WILL HAVE NO ERROR USING SUCCESSIVE OVER RELAXATION METHOD...
IDENTIFY THE ERROR SO THAT THE CODE WILL HAVE NO ERROR USING SUCCESSIVE OVER RELAXATION METHOD function [x,numIter,omega] = gaussSeidel(func,x,maxIter,epsilon) % Solves Ax = b by Gauss-Seidel method with relaxation. % USAGE: [x,numIter,omega] = gaussSeidel(func,x,maxIter,epsilon) % INPUT: % func = handle of function that returns improved x using % x = starting solution vector % maxIter = allowable number of iterations (default is 500) % epsilon = error tolerance (default is 1.0e-9) % OUTPUT: % x = solution vector %...
Find the error in each of the following code segments and explain how to correct it....
Find the error in each of the following code segments and explain how to correct it. x = 1; while ( x <= 10 ); x++; } for ( y = .1; y != 1.0; y += .1 System.out.println( y ); switch ( n ) { case 1: System.out.println( “The number is 1” ); case 2: System.out.println( “The number is 2” ); break; default: System.out.println( “The number is not 1 or 2” ); break; } The following code should print...
Create code In visual Basic, Windows forms that uses case statements to convert the day of...
Create code In visual Basic, Windows forms that uses case statements to convert the day of the week (entered by the user into an integer. (Sunday = 1, Monday = 2, etc.) For this code, think about error checking. What will your code do if the user enters “dog” for example (which is not a day of the week)? What will your code do if the user enters a number or other incorrect input?
Identify each of the following experimental occurrences as contributing to systematic error “S”, random error “R”,...
Identify each of the following experimental occurrences as contributing to systematic error “S”, random error “R”, both types of error “B”, or neither (does not cause error) “N” Write the code letters S, R, B or N, as appropriate, in the space beside the phrase. ____ reading a meniscus from above the plane of the calibration mark ____ reading a meniscus in the plane of the calibration mark, but with limits of human visual acuity ____ transferring analyte solution from...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected format onto your answer sheet. You may assume that din is a 16-bit vector and that the ld, lr and cl inputs are 1-bit wide. lp: process(clk) signal reg : std_logic_vector(15 downt begin if cl=’1’ then reg := (others:=’0’); else if clk=’1’ and clkevent then if ld=’1’ reg <= din; end if; if lr=’1’ then reg := reg(14 downto 0) & “0 else reg...
Create programs in Visual Basic which perform each of the following: Explain the different design choices...
Create programs in Visual Basic which perform each of the following: Explain the different design choices (syntax) for option in each language Document the programs using Flowcharts Each programs source code must be included – label each with the language used a) Nested two-way selection statements b) Multiple-way selection statement c) Iterative Statements – Counter controlled and Logic controlled d) After the Counter Controlled Iterative successfully completes – Display “This was a success” on the screen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT