Jump to content

Need Help

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Krypton

Krypton

    Newbie

  • Members
  • Pip
  • 4 posts
Hello. I'm looking to learn C#, seeing as it is a more powerful one than VB.Net (The language I am very good at.) but my knowledge in VB.Net doesn't seem to help me learning C#.

I'm looking to make a simple name thing... you write your name in the textbox, continue - new form opens and what you displayed there, is displayed in a label.
In VB.Net, it easily is done with:
TextBox1.Text = frmDisplay.lblName.Text

How would I do this in C#? Exactly the same? - Like this:?
textBox1.Text == frmDisplay.lblName.Text

I need help on this, really.
Thanks,
Krypton

#2
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
== is an equivalency operator,

Your translation would look like this

textBox1.Text = frmDisplay.lblName.Text;
Seriously, just add the ; to the end =)

#3
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
And theres one more thing here too. It's a weirdness with VB actually.
In VB it seems like many developers only ever use a single instance of a form. So they almost treat those forms as static. And I think it's handled ok.

if the code you were writing in C# were inside the form, as I suspect, and I assume you've actually named the form class frmDisplay, and that's not the name of a variable, you might actually just do this...

textBox1.Text = lblName.Text;

or you could kick the dead horse like this...

this.textBox1.Text = this.lblName.Text;  //where this refers to the current instance of the object the code is executing in.


#4
Krypton

Krypton

    Newbie

  • Members
  • Pip
  • 4 posts
Yeah, I've noticed most VB functions are the same in C#, just with a semi-colon (;) at the end.
Thanks for the help!

#5
Professor Green

Professor Green

    Newbie

  • Members
  • Pip
  • 5 posts
as you know VB.NET , then you have to make attention to take care of the MODIFIERS of TEXTBOX or LABLE .... make it PUBLIC , the default is private ... that's because you're working between forums

and what @sam_coder said is true

thank you , sam_coder and Krypton

Edited by Professor Green, 14 July 2011 - 05:38 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users