Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2007, 09:02 AM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default sub main missing.

I was write the code. i.e.

------------

Imports System.IO
Imports System.Windows.Forms
Imports System.Drawing




Public Class FrmRollTwellveDice
    Inherits System.Windows.Forms.Form

    'button for rolling dice
    Friend WithEvents cmdRoll As System.Windows.Forms.Button

    'Labels to display die images
    Friend WithEvents lblDie1 As System.Windows.Forms.Label
    Friend WithEvents lblDie2 As System.Windows.Forms.Label
    Friend WithEvents lblDie3 As System.Windows.Forms.Label
    Friend WithEvents lblDie4 As System.Windows.Forms.Label
    Friend WithEvents lblDie5 As System.Windows.Forms.Label
    Friend WithEvents lblDie6 As System.Windows.Forms.Label
    Friend WithEvents lblDie7 As System.Windows.Forms.Label
    Friend WithEvents lblDie8 As System.Windows.Forms.Label
    Friend WithEvents lblDie9 As System.Windows.Forms.Label
    Friend WithEvents lblDie10 As System.Windows.Forms.Label
    Friend WithEvents lblDie11 As System.Windows.Forms.Label
    Friend WithEvents lblDie12 As System.Windows.Forms.Label

    'display roll frequencies
    Friend WithEvents displayTextBox As _
    System.Windows.Forms.TextBox

    'Visual Studio .NET generated code

    'declarations
    Dim randomObject As Random = New Random
    Dim ones, twos, threes, fours, fives, sixes As Integer

    Private Sub cmdRoll_Click _
        (ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles cmdRoll.Click

        'assign random faces to 12 dice using DisplayDice
        DisplayDie(lblDie1)
        DisplayDie(lblDie2)
        DisplayDie(lblDie3)
        DisplayDie(lblDie4)
        DisplayDie(lblDie5)
        DisplayDie(lblDie6)
        DisplayDie(lblDie7)
        DisplayDie(lblDie8)
        DisplayDie(lblDie9)
        DisplayDie(lblDie10)
        DisplayDie(lblDie11)
        DisplayDie(lblDie12)

        Dim total As Integer = ones + twos + threes + fours + fives + sixes

        Dim output As String

        'display frequencies of faces
        output = "Face" & vbTab & vbTab & "Frequency" & vbTab & "percent"

        output &= vbCrLf & "1" & vbTab & vbTab & ones & _
        vbTab & vbTab & String.Format("{0:P}", ones / total)

        output &= vbCrLf & "2" & vbTab & vbTab & twos & _
        vbTab & vbTab & String.Format("{0:P}", twos / total)

        output &= vbCrLf & "3" & vbTab & vbTab & threes & _
        vbTab & vbTab & String.Format("{0:P}", threes / total)

        output &= vbCrLf & "4" & vbTab & vbTab & fours & _
        vbTab & vbTab & String.Format("{0:P}", fours / total)

        output &= vbCrLf & "5" & vbTab & vbTab & fives & _
        vbTab & vbTab & String.Format("{0:P}", fives / total)

        output &= vbCrLf & "6" & vbTab & vbTab & sixes & _
        vbTab & vbTab & String.Format("{0:P}", sixes / total) & vbCrLf

        displayTextBox.Text = output
    End Sub 'cmdRoll_Click

    'displlay a single die image
    Sub DisplayDie(ByVal dieLabel As Label)
        Dim face As Integer = randomObject.Next(1, 7)

        dieLabel.Image = _
        Image.FromFile(Directory.GetCurrentDirectory & _
        "\Images\die" & face & ".png")

        'maintain count of die faces
        Select Case face

            Case 1
                ones += 1

            Case 2
                twos += 1

            Case 3
                threes += 1

            Case 4
                fours += 1

            Case 5
                fives += 1

            Case 6
                sixes += 1

        End Select

    End Sub 'DisplayDie

End Class

-------------
Now the problem is that when I run this code it shows the error which is

'Sub Main' was not found in '_6RollTwelveDice16.Module1'.

Please anybody solve my problem.




 
Old June 19th, 2007, 09:38 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you created a 'Console Application'?

You should create a 'Windows application'!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Main Builder Delthor Java Basics 0 January 3rd, 2008 07:41 AM
C++ and main for a beginner fords4me78 C++ Programming 2 February 27th, 2006 09:32 PM
Missing Sub Main in Chapter One, Exercise One mmcdonal BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 6 October 27th, 2004 06:06 PM
Main Method CodeMonkeys C# 1 August 11th, 2004 06:51 AM
To Imar: Re: Sub Main shadowpug VB.NET 2002/2003 Basics 1 July 26th, 2003 02:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.