2 Replies - 441 Views - Last Post: 15 June 2012 - 05:45 PM Rate Topic: -----

#1 Killer563489  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-June 12

Visual C# Studio 2010 Express Problems

Posted 15 June 2012 - 05:31 PM

I need help with Visual C# 2012 Express. I am trying to make my "play game" button verify that the user name is "Username" and then go to the game window. I am getting errors for the username verification, and I have no idea how to make it open another window. I have this:

 private void playgamebutton_Click(object sender, EventArgs e)
        {
            if userTextBox = "Username" then
                (Insert Code to make it Open another Window here)
        }


I've tried following the errors like putting
 windowsformsapplication1.form1.userTextBox
instead of the
 userTextBox 
But it didn't work. It just gives me different errors.

I am currently in the learning stage, so I am not very good at C# yet. I hope somebody has an answer for me.

Thanks in advanced!

Is This A Good Question/Topic? 0
  • +

Replies To: Visual C# Studio 2010 Express Problems

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5540
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Visual C# Studio 2010 Express Problems

Posted 15 June 2012 - 05:38 PM

Stop trying to architect a program while you are still learning the basics of C#. It just never works. Its like saying you are going to learn home architecting WHILE you hammer boards together without a blueprint, and try to learn both new skills at the same time.

First learn the language. Do a couple hundred tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.

Then later you can start architecting your own simple stuff. Build a calculator. Build a DVD library program. Etc. Stuff that doesn't involve the complexity of a game.

Then move up to games.



There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

Quote

Where do I start?


You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.


If this sounds like you

Newbie/Rookie said:

I have a little programming experience but I need to write ...
read this section
Spoiler


Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.



Resources, references and suggestions for new programmers. - Updated Mar 2012
Spoiler

Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5540
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: Visual C# Studio 2010 Express Problems

Posted 15 June 2012 - 05:45 PM

View PostKiller563489, on 15 June 2012 - 06:31 PM, said:

I have this:

 private void playgamebutton_Click(object sender, EventArgs e)
        {
            if userTextBox = "Username" then
                (Insert Code to make it Open another Window here)
        }


This isn't even valid C# syntax. You seem to be just making it up as you go along. Let's start with the first line you actually wrote:
if userTextBox = "Username" then


  • There is no "then" in C# if constructs.
  • userTextBox is a textbox not a string. A textbox will never be equal to a string. The textbox has a .Text property you can check.
  • A C# if requires parenthises around the comparison.
  • = is an assignment operator, not a comparritor.
  • == is a comparitor.
    int x = 5; // Assignment
    if (x == 5)  // Comparrison
    


So it should look more like this
if (userTextBox.Text == "username")
{
   // Do this stuff here
}


Nobody here is going to be your personal tutor and hand-hold you through learning every C# statement. You have to take responsibility for your own education. Pick up a C# book.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1