Beginner VB.Net - needs code help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Beginner VB.Net - needs code help

  1. #1
    Join Date
    Jul 2005
    Posts
    1

    Beginner VB.Net - needs code help

    I am teaching myself VB.NET - going through a code example that I can't get to run. Can someone take a look at this and tell me what is wrong ?

    ******************************************************

    Module Module1

    Sub Main()
    Dim Scores(2) As Integer
    Scores(0) = 45
    Scores(1) = 55
    Scores(2) = 65
    For intLoopIndex As Integer = 0 To UBound(Scores)
    Console.WriteLine("Score(" & intLoopIndex & ") = _
    " & Scores(intLoopIndex))
    Next intLoopIndex
    Console.WriteLine("Press Enter to continue...")
    Console.ReadLine()

    End Sub

    End Module


    ************************************************
    Thank you!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    You cannot break a line in the middle of a string literal. Either remove the line-continuation character...
    Code:
    Module Temp
        Sub Main()
            Dim Scores(2) As Integer
            Scores(0) = 45
            Scores(1) = 55
            Scores(2) = 65
            For intLoopIndex As Integer = 0 To UBound(Scores)
                Console.WriteLine("Score(" & intLoopIndex & ") = " & Scores(intLoopIndex))
            Next intLoopIndex
            Console.WriteLine("Press Enter to continue...")
            Console.ReadLine()
    
        End Sub
    End Module
    ...or break the line between strings, rather than in the middle of a string:
    Code:
    Module Temp
        Sub Main()
            Dim Scores(2) As Integer
            Scores(0) = 45
            Scores(1) = 55
            Scores(2) = 65
            For intLoopIndex As Integer = 0 To UBound(Scores)
                Console.WriteLine("Score(" & intLoopIndex & _ 
                    ") = " & Scores(intLoopIndex))
            Next intLoopIndex
            Console.WriteLine("Press Enter to continue...")
            Console.ReadLine()
    
        End Sub
    End Module
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Why integer and int32
    By Michael Culley in forum .NET
    Replies: 154
    Last Post: 05-10-2002, 12:06 PM
  2. Are Comments a Waste of Time?
    By Glen Kunene in forum Java
    Replies: 25
    Last Post: 04-22-2002, 05:45 PM
  3. From VB.net to C#
    By Thomas Eyde in forum .NET
    Replies: 195
    Last Post: 04-12-2002, 04:51 PM
  4. wot is CLR
    By lostguy in forum .NET
    Replies: 8
    Last Post: 04-03-2002, 06:41 PM
  5. Replies: 17
    Last Post: 01-17-2002, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center