Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Need changes to console application example in VB.NET !!

CAN YOU MODIFY THE BELOW PROGRAM AND MAKE IT WORK ?
========================================


Module Module1

    Sub Main()
       
        'Reading values
         
        Console.WriteLine("Please input the following info !")
        Console.WriteLine()  

        Console.WriteLine("Enter your name : ")
        Dim x As String = Console.Read()              //WRONG
        Console.WriteLine("Enter your age : ")
        Dim y As Integer = Console.Read()           //WRONG
        Console.WriteLine("Enter your dob : ")
        Dim z As DateTime = Console.Read()       //WRONG
        Console.WriteLine("Enter your gender (M/F) : ")
        Dim a As ----------------------------           //Need this line of code

        Console.ReadLine()

        'Writing values
         
        Console.WriteLine("You have input the following info !")
        Console.WriteLine()  
     
        Console.WriteLine("Your name : " & x)
        Console.WriteLine("Your age : " & y)
        Console.WriteLine("Your dob : " & z)
        Console.WriteLine("Your gender (M/F) : & a)

        Console.ReadLine()

    End Sub

End Module
0
kishore_peddi
Asked:
kishore_peddi
  • 2
  • 2
1 Solution
 
VoteyDiscipleCommented:
If Console.WriteLine() writes a line of text, what would read a line of text?
0
 
kishore_peddiAuthor Commented:
Can you please tell me how to declare a single character (Y/N) in VB.NET ?

0
 
kishore_peddiAuthor Commented:

Here is the code
==========

Module Module1

    Sub Main()

        'Reading values

        Console.WriteLine("Please input the following info !")
        Console.WriteLine()

        Console.Write("Enter your name : ")
        Dim x As String = CStr(Console.ReadLine())
        Console.Write("Enter your age : ")
        Dim y As Integer = CInt(Console.ReadLine())
        Console.Write("Enter your dob : ")
        Dim z As DateTime = CDate(Console.ReadLine())
        Console.Write("Enter your gender (M/F) : ")
        Dim a As Char = Console.ReadLine()

        'Need gap

        Console.WriteLine()

        'Writing values

        Console.WriteLine("You have input the following info !")
        Console.WriteLine()

        Console.WriteLine("Your name : " & x)
        Console.WriteLine("Your age : " & y)
        Console.WriteLine("Your dob : " & z)
        Console.WriteLine("Your gender (M/F) : " & a)

        Console.ReadLine()

    End Sub

End Module

How we can restrict the user input for name (let us say 10 characters) while he is typing at console window ? Appreciate your time and patience !!
0
 
VoteyDiscipleCommented:
I Googled "VB .NET datatypes" and found a number of pages that list types available in VB .NET.  

For that matter, what would you guess a type that stores a single character might be called?  Languages have some funky keywords, but most aren't THAT bad.  (-:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now