Results 1 to 2 of 2

Thread: I'm STUCK and stupid!!!!!!!!!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Location
    Portsmouth, England
    Posts
    1

    I'm STUCK and stupid!!!!!!!!!!!

    Ok, i recently got vb.net to take my first steps into programming because i find it enjoyable and i'd like to maybe learn some more complex languages eventually and make loads of money.

    Anyway, i have brought Sams teach yourself vb .net in 21 days to teach myself and so far it seems great and i think i've understood everything but i'm stuck on day 2. the question at the end of the chapter is"Using one For Loop inside another (nesting two for loops), display all the elements of a 3x3 two dimensional array."

    Unfortunately i'm stupid, i've understood everything so far but it expects you to use your own initiative to work this one out but i've tried real hard and here's what i've come up with:

    Dim intinput(2, 2) As Integer
    intinput(0, 0) = 5
    intinput(0, 1) = 10
    intinput(0, 2) = 20
    intinput(1, 0) = 30
    intinput(1, 1) = 40
    intinput(1, 2) = 50
    intinput(2, 0) = 60
    intinput(2, 1) = 70
    intinput(2, 2) = 80

    so theres my two dimensional array with 3 columns and 3 rows, all assigned a value correctly i hope.
    next it goes like this:

    For index As Integer = (0) To UBound(intinput)
    Console.WriteLine("Score is (" & intinput & ") = " & intinput(index))
    Next

    i've got this far now im completely confused, i used a similar thing to succesfully display all the results in a simple 1 dimensional array. I am using a console application for this as the book recommends this for starting out.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    VB Code:
    1. dim x as integer
    2. dim y as integer
    3.  
    4. For x = 0 to intinput.GetUpperBound(0)
    5.    For y = 0 to intinput.GetUpperBound(1)
    6.        Console.Writeline(intinput(x,y))
    7.    Next
    8. Next
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width