PC Review


Reply
Thread Tools Rate Thread

Can anyone help me answer these questions or nay of them as im struggling with understanding the VBA concept and have an exam in it next week. Or anyone no some good books i would really apreciate.. thanks

 
 
paul
Guest
Posts: n/a
 
      27th May 2007

Q1/

a/ Describe 5 different data types used in Visual BASIC for
Applications. Each description should contain a definition of the data
type and an example of the type of data it can hold.



Q2/

a/ Demonstrate by example how a WHILE loop may be used. (10 marks)

b/ To demonstrating the use of a FOR loop write a short section of VBA
code to add up the first 10 elements in the array Data(). (15 marks)


Q3/

a/ The variable Colour is to be set using if statements depending upon
the values stored in the variables LandCover and Slope depending upon
the following rules:
· Colour is to be set to 1 if LandCover is less than 4 and slope is
less than 10
· Colour is to be set to 2 if LandCover is less than 10 but greater
than or equal to 4 and lope is less than 10
· Colour is to be set to 3 if Slope is greater than 10
· (13 marks)

b/ When passing arguments to a sub routine what do the terms passed by
address and passed by value mean? (5 marks)

c/ In order to georectify a point given as x,y coordinates the points
are represented by a vector the points are multiplied by a correction
matrix and a translation vector added to the result.
Write the VBA commands to place the two raw coordinates into the
array Coord(2) and the four correction parameters into the array
M(2,2) (7 marks)

Q4/

As part of a statistical analysis of temperature data a subroutine is
required to return the largest and smallest value of an array of a
given length.

If the calling line is:

CALL BigLittle(A, Length, Max, Min)

Write the required subroutine where A is the array of temperature
data, Length the number of temperature records to be searched, and Max
and Min the returned values. (25 marks)


Q5/

When using VBA with excel it is important to be able to read and
write to the excel spreadsheet. Write VBA commands to perform the
following tasks:

a/ Place in the variable X the number in the cell A4 (4 marks)

b/ Place in the cell A7 the text "Hello world" (4 marks)

c/ Place a message box on the screen giving the message contained in
the string variable, Prompt$ (4 marks)

d/ Read the area designated by the string variable Area$ into a one
dimensional array called Input() (4 marks)

e/ Read the 5 column and 3 row of the currently active spreadsheet
into the array element A(2,4) (4 marks)

f/ Read the value in the cell A9 from worksheet, sheet1 into the
variable, Step (5 marks)

Q6/

The VBA code in appendix A was written by a not very good programmer
to sort an array of numbers into ascending order.

a/ The programmer forgot to document the code to explain how it works.
Write an explanation of how the code works and explain exactly what it
is doing. (20 marks)

b/ The programmer also made an error in writing the program. Identify
this error (5 marks)

Appendix A Candidate number ________________



Sub test()
Dim data(10) As Single
Dim n As Integer

' data is acquired here

Call sort(data, n)
End Sub

Sub sort(A, length)
Dim I, J As Integer
Dim X As Single
For i = 1 To length
For j = 1 To (length - i)
If A(j) < A(j + 1) Then
x = A(j + 1)
A(j + 1) = A(j)
A(j) = x
End If
Next j
Next i

End Sub

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      27th May 2007
We do NOT do homework, especially pro bono.

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"paul" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

Q1/

a/ Describe 5 different data types used in Visual BASIC for
Applications. Each description should contain a definition of the data
type and an example of the type of data it can hold.



Q2/

a/ Demonstrate by example how a WHILE loop may be used. (10 marks)

b/ To demonstrating the use of a FOR loop write a short section of VBA
code to add up the first 10 elements in the array Data(). (15 marks)


Q3/

a/ The variable Colour is to be set using if statements depending upon
the values stored in the variables LandCover and Slope depending upon
the following rules:
· Colour is to be set to 1 if LandCover is less than 4 and slope is
less than 10
· Colour is to be set to 2 if LandCover is less than 10 but greater
than or equal to 4 and lope is less than 10
· Colour is to be set to 3 if Slope is greater than 10
· (13 marks)

b/ When passing arguments to a sub routine what do the terms passed by
address and passed by value mean? (5 marks)

c/ In order to georectify a point given as x,y coordinates the points
are represented by a vector the points are multiplied by a correction
matrix and a translation vector added to the result.
Write the VBA commands to place the two raw coordinates into the
array Coord(2) and the four correction parameters into the array
M(2,2) (7 marks)

Q4/

As part of a statistical analysis of temperature data a subroutine is
required to return the largest and smallest value of an array of a
given length.

If the calling line is:

CALL BigLittle(A, Length, Max, Min)

Write the required subroutine where A is the array of temperature
data, Length the number of temperature records to be searched, and Max
and Min the returned values. (25 marks)


Q5/

When using VBA with excel it is important to be able to read and
write to the excel spreadsheet. Write VBA commands to perform the
following tasks:

a/ Place in the variable X the number in the cell A4 (4 marks)

b/ Place in the cell A7 the text "Hello world" (4 marks)

c/ Place a message box on the screen giving the message contained in
the string variable, Prompt$ (4 marks)

d/ Read the area designated by the string variable Area$ into a one
dimensional array called Input() (4 marks)

e/ Read the 5 column and 3 row of the currently active spreadsheet
into the array element A(2,4) (4 marks)

f/ Read the value in the cell A9 from worksheet, sheet1 into the
variable, Step (5 marks)

Q6/

The VBA code in appendix A was written by a not very good programmer
to sort an array of numbers into ascending order.

a/ The programmer forgot to document the code to explain how it works.
Write an explanation of how the code works and explain exactly what it
is doing. (20 marks)

b/ The programmer also made an error in writing the program. Identify
this error (5 marks)

Appendix A Candidate number ________________



Sub test()
Dim data(10) As Single
Dim n As Integer

' data is acquired here

Call sort(data, n)
End Sub

Sub sort(A, length)
Dim I, J As Integer
Dim X As Single
For i = 1 To length
For j = 1 To (length - i)
If A(j) < A(j + 1) Then
x = A(j + 1)
A(j + 1) = A(j)
A(j) = x
End If
Next j
Next i

End Sub

 
Reply With Quote
 
Helmut Weber
Guest
Posts: n/a
 
      27th May 2007
Hi Paul,

others answering the questions put to you
won't get you far, hopefully.

Your teacher didn't declare variables properly.
First, there is no use of integer,
for performance issues, in theory.
Use long.
Second, your teacher declared I as variant.
No good as well.

Your teacher wouldn't like to hear that.

What he or she would like to see is
something wrong in the bubble-sorting.

Good luck.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"








 
Reply With Quote
 
paul
Guest
Posts: n/a
 
      28th May 2007
thanks very much for that, thats very helpful, could you possibly
explain why you need to declare variables and why I as a variant is
not good?

thanks again





On 27 May, 20:50, Helmut Weber <nbhymsjxd...@mailinator.com> wrote:
> Hi Paul,
>
> others answering the questions put to you
> won't get you far, hopefully.
>
> Your teacher didn't declare variables properly.
> First, there is no use of integer,
> for performance issues, in theory.
> Use long.
> Second, your teacher declared I as variant.
> No good as well.
>
> Your teacher wouldn't like to hear that.
>
> What he or she would like to see is
> something wrong in the bubble-sorting.
>
> Good luck.
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"



 
Reply With Quote
 
Helmut Weber
Guest
Posts: n/a
 
      28th May 2007
Hi Paul

>thanks very much for that, thats very helpful, could you possibly
>explain why you need to declare variables and why I as a variant is
>not good?


good questions, it's only that good answers are hard to find.

I don't know, maybe compare programming
with what you find in a construction kit for a car.

In the instructions you may find a list of all the parts:

nuts, screws, washers, wheels, axes,
something ' variant! ?

Still better would be,
nuts(16) , screws(16), washers(32),
wheels(4), axes(2),
something ' variant! ?

All that corresponds to declarations.

So you know what you have to deal with,
except the variant.
Otherwise, it's just stumbling in the dark.

In addition, for the sorting,
see help for "option base".

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"













 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not understanding simple concept Bryan Microsoft VB .NET 6 27th Nov 2006 04:48 PM
Struggling With Concept One Handed Man \( OHM#\) Microsoft ASP .NET 1 12th Jun 2004 03:07 PM
Re: Struggling With Concept Phil Winstanley [Microsoft MVP ASP.NET] Microsoft ASP .NET 1 12th Jun 2004 01:12 PM
So many questions with VB.NET Web applications (active server pages)... any good books? David Brewster Microsoft ASP .NET 7 20th Jan 2004 03:46 PM
So many questions with VB.NET Web applications (active server pages)... any good books? David Brewster Microsoft VB .NET 1 19th Jan 2004 04:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:23 PM.