Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics 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 August 26th, 2007, 01:27 AM
Registered User
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Console.read command

Hi,

    I am learning VB 2005. I started with a basic console application for calculating square root of a number. The code is as below:

******************
Module Module1

    Sub Main()
        Dim y As Integer
        Console.WriteLine("Enter number !")
        y = Console.Read()
        MsgBox("Square root of " & y & " is " & System.Math.Sqrt(y))
    End Sub

End Module
*******************

The above is not reading the value of y properly. If I enter '1', it reads it as '48' and gives result accordingly. If I enter '2', it reads it as '49'.

Is there any setting required to be done ?

Thanks.

 
Old August 26th, 2007, 03:47 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this :

Module Module1

    Sub Main()
        Dim y As Integer
        Console.Write("Enter number !")
        y = Console.ReadLine()
        MsgBox("Square root of " & y & " is " & System.Math.Sqrt(y))
    End Sub

End Module


 
Old August 26th, 2007, 09:33 AM
Registered User
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. It worked.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Console application but no Console gamotter C# 2 August 22nd, 2007 11:41 PM
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM





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