5 Replies - 222 Views - Last Post: 06 December 2012 - 08:06 AM Rate Topic: -----

#1 Untalented  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 134
  • Joined: 31-January 12

Basic If Else Problem

Posted 06 December 2012 - 06:58 AM

Hi i am new to VB.net

Module Module1

    Sub Main()
        Dim x As Integer
        Console.Write("Enter Number: ")
        Console.ReadLine()
        If x >= 50 Then
            Console.WriteLine("PASSED")
        Else

            Console.WriteLine("FAILED")

        End If
        Console.ReadLine()

    End Sub

End Module





I'm following this format
If <condition> Then
	<statements>
ElseIf <condition> Then
	<statements>
Else
	<statements done if all conditions false>
End If



But why am i still getting failed when i input more than 50?


and do you know some website or ebook that have vb.net console application tutorial? so i could read


Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Basic If Else Problem

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Basic If Else Problem

Posted 06 December 2012 - 07:37 AM

You need to assign what you read from console, to some variable. Example:
        Dim myName As String 'this is the variable, that will hold users input
        Console.WriteLine("Please insert your name: ") 'you display a message to user
        myName = Console.ReadLine() 'here you assign users input to myName variable

        Console.WriteLine("Hi {0}! It's nice to see you learning VB.NET. Good luck {0}!", myName) 'now you can see as output what you assigned to myName variable

        Console.ReadLine() 'to prevent immediate program termination


Was This Post Helpful? 1
  • +
  • -

#3 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 385
  • View blog
  • Posts: 2,648
  • Joined: 12-January 10

Re: Basic If Else Problem

Posted 06 December 2012 - 07:41 AM

I dont see where you assigned x's info.





 x = Console.ReadLine()  


the above is addigning x variable to the console.readline()
Was This Post Helpful? 1
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8365
  • View blog
  • Posts: 31,080
  • Joined: 12-June 08

Re: Basic If Else Problem

Posted 06 December 2012 - 07:52 AM

You never set the value of 'x'. That console readline needs to go somewhere!

Son of a gun.. I should have refreshed. Too busy closing other topics. *sigh* Thanks everyone above this post!

This post has been edited by modi123_1: 06 December 2012 - 07:53 AM

Was This Post Helpful? 1
  • +
  • -

#5 Untalented  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 134
  • Joined: 31-January 12

Re: Basic If Else Problem

Posted 06 December 2012 - 08:03 AM

Thanks everyone!

I hope you could give me some good vb.net console application tutorial link or ebook.

Thank again

This post has been edited by Untalented: 06 December 2012 - 08:04 AM

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8365
  • View blog
  • Posts: 31,080
  • Joined: 12-June 08

Re: Basic If Else Problem

Posted 06 December 2012 - 08:06 AM

... a tutorial for *WHAT*? We have a ton of tutorials if you click the link at the top of the page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1