Solved

creating a menue in vb.net help required

Posted on 2011-03-17
3
279 Views
Last Modified: 2012-05-11
I am creating a menu in vb.net 2005. It is in console mode and it has if I press 1 it takes me to a different file and if press 2 to a different file and so on. can anybody tell how this can be achieved using coding?
0
Comment
Question by:mahmood_786
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35159839
You display the menu using Console.WriteLine() and Console.Write().

To get a value from the user, output a prompt with WriteLine() then wait for an answer back with ReadLine().

For example:
Module Module1

    Sub Main()
        Console.WriteLine("Main Menu:")
        Console.WriteLine("----------------------------")
        Console.WriteLine("(1) Chess")
        Console.WriteLine("(2) Poker")
        Console.WriteLine("(3) Global Thermonuclear War")
        Console.WriteLine("")
        Console.WriteLine("(4) Exit")
        Console.WriteLine("----------------------------")
        Console.Write("Your choice: ")
        Dim response As String = Console.ReadLine()
        Select Case response
            Case "1"

            Case "2"

            Case "3"
                Console.Write("Who shall we attack first? ")
                Dim target As String = Console.ReadLine()

            Case "4"

            Case Else
                Console.WriteLine("Unknown Response")

        End Select

        Console.WriteLine("Press Enter to Continue")
        Console.ReadLine()
    End Sub

End Module

Open in new window

0
 

Author Comment

by:mahmood_786
ID: 35160959
That is a nice example. But I need bit of more explaination what if it is a prgraomme like if someone presses 1 it takes you to the no to a differentcalss adn if press 2 to a siddernet calss. . I measn suppose there are 3 classes in the vb.net programme and calss 1 is called "customer", 2 is called "quotation" 3 is called "Help". So when 1 is pressed it will start like this enter the name of file to be created, when someone enters the file it name and hits enter it will say  tilte:  one title is entered it says (when enter is pressed) full name:  and so on. Similalry if 3 is presssed it shows help file and when 2 is pressed it says , enter the interest rate , enter the no. of months....etc....

0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35161016
Ok...you could do:
Select Case response
            Case "1"
                Console.Write("FileName: ")
                Dim FileName As String = Console.ReadLine()
                Console.Write("Title: ")
                Dim Title As String = Console.ReadLine()
                Console.Write("Full Name: ")
                Dim FullName As String = Console.ReadLine()

                ... now do something with "FileName", "Title", and "FullName"...

            Case "2"

            Case "3"

            Case Else
                Console.WriteLine("Unknown Response")

        End Select

Open in new window

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question