Results 1 to 4 of 4
  1. #1
    NastyAttraction's Avatar
    Join Date
    Jun 2015
    Gender
    male
    Location
    Canada
    Posts
    71
    Reputation
    10
    Thanks
    5
    My Mood
    Drunk

    Alright I need some help

    So I've been teaching myself Visual Basic / Watching tutorials when I dont understand lately, and I'm trying to make a console application that when executed will ask you for your name, then output Hello (Your name)

    Here's my code, I have no clue why it doesnt work...

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Changes Title
                Console.Title = "Test";
                
                //Declares "Name" As A String
                //And Sets It Equal To The Value
                //Of Console.ReadLine();
                string Name = Console.ReadLine();
    
                //Outputs A Question
                Console.WriteLine("Whats Your Name?");
    
                //Reads The Console.WriteLine
                Console.ReadLine();
    
                //Outputs Hello and then the string value of Name
                Console.WriteLine("Hello ", Name);
    
                //Keeps Console Open
                Console.ReadLine();
            }
        }
    }

  2. #2
    ISD's Avatar
    Join Date
    Jun 2014
    Gender
    male
    Location
    Germany
    Posts
    97
    Reputation
    17
    Thanks
    2,074
    My Mood
    Fine
    But that's C#, not VB.NET, m8.
    Wrong Section or C&P Code?

    EDIT:
    If you want it in VB.NET, then here:
    Code:
    Module Module1
    
        Dim Name As String
    
        Sub Main()
            Console.Title = "Test"
            Console.WriteLine("> What's your name?")
            If ConsoleKey.Enter Then
                Name = Console.ReadLine()
                Console.WriteLine("> Hello, " & Name & "!")
            End If
            Console.ReadLine()
        End Sub
    
    End Module
    Last edited by ISD; 12-26-2015 at 07:22 AM.

  3. #3
    Yemiez's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Sweden
    Posts
    2,566
    Reputation
    731
    Thanks
    16,280
    My Mood
    Devilish
    This code is not VB.net, moved to C# section.

    Also doing ReadLine before you ask the question doesn't make sense, how will the user know what to type
    before the question has been asked?

    Code:
            static void Main(string[] args)
            {
                //Changes Title
                Console.Title = "Test";
                
              
    
                //Outputs A Question
                Console.WriteLine("Whats Your Name?");
    
                 //Declares "Name" As A String
                //And Sets It Equal To The Value
                //Of Console.ReadLine();
                string Name = Console.ReadLine();
    
                //Outputs Hello and then the string value of Name
                Console.WriteLine("Hello {0}", Name);
    
                //Keeps Console Open
                Console.ReadLine();
            }
    ^ Makes more sense.

    Also notice the {0} added, without it the value of 'Name' wont be appeneded to the message.
    Last edited by Yemiez; 12-27-2015 at 02:49 AM.

  4. #4
    NastyAttraction's Avatar
    Join Date
    Jun 2015
    Gender
    male
    Location
    Canada
    Posts
    71
    Reputation
    10
    Thanks
    5
    My Mood
    Drunk
    I apologize, I'm Dumb -_-* I'm used to setting variables first, and then including them in other events since static void main is globaly viewable by the entire program. Thanks Yamiez and I apologize, I didnt realize It was visual studio, It said visual so I was like Im gonna be smrt and post in the visual section.

Similar Threads

  1. [Help Request] Need some help with my Project
    By Vertual~ in forum Call of Duty Modern Warfare 3 Help
    Replies: 2
    Last Post: 01-30-2012, 04:33 PM
  2. [Help Request] need some help plz
    By crappule20 in forum Combat Arms Help
    Replies: 2
    Last Post: 12-10-2011, 11:25 AM
  3. [Help Request] Need some help with my server premisions
    By pero122 in forum Minecraft Help
    Replies: 5
    Last Post: 11-07-2011, 10:55 PM
  4. [Help Request] Need some help to make a bot
    By Domo in forum Vindictus Help
    Replies: 6
    Last Post: 05-21-2011, 10:15 AM
  5. [Help Request] I need some help with binding eps7
    By v1zhaixingv1 in forum Vindictus Help
    Replies: 3
    Last Post: 05-18-2011, 09:25 PM