Solved

creating a menue in vb.net help required

Posted on 2011-03-17
3
259 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now