Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

creating a menue in vb.net help required

Posted on 2011-03-17
3
Medium Priority
?
310 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 86

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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

772 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