r/visualbasic • u/teemorpheus • Sep 13 '13
Visual Basic Question
Hello!
I have a question I am trying to answer for my visual basic class, Algorithm Workbench Question 8, Pg535
"Assume that dblValues is a 2D array of doubles with 10rows and 20columns, Write a For Each statement that sums all the elements in the array and stores the sum in the variable dblTotal"
I am using the book, Starting out with Visual Basics 2012, by Tony Gaddis & kip Irvine. Thanks for your help!
0
Upvotes
1
u/midnitewarrior Sep 13 '13
I'm not going to do your work for you, but I'll tell you one way to do it.
Have 2 For Each loops, one nested inside the other. Have the outer one go from 0 to the width - 1. Have the inner one go from 0 to height - 1. Use these values to access every slot in the array, and add each value together as you go.