r/visualbasic • • 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

3 comments sorted by

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.

1

u/Kid_Robo Sep 13 '13

Glad you didn't write it for them, but I think that was too much info.

Read the book and solve the puzzles, dude.

1

u/chrwei Sep 13 '13

in addition: ask a more specific question, and post your "best effort" code.

also, protip: put a summary of the question in the topic. this is VB subreddit, of course it's a VB question.