O'Reilly Forums: Save The Humans - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Save The Humans start button private sub vs private void

#1 User is offline   Jason Vearing 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 11-May 14

Posted 11 May 2014 - 03:33 PM

I am up to page 29 in Save the Humans where you start to add C# code. When I click on the start button the code I get creates a sub not a void. I tried to continue but encountered problems so i have come back to this point. Have I done something wrong to not get a void.

Class MainWindow
Random random = new Random();

Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
End Sub

Private Sub AddEnemy()
ContentControl enemy = New ContentControl ();
enemy.Template = Resources["EnemyTemplate] as ControlTemplate;
AnimateEnemy(enemy, 0, playArea.ActualWidth = 100, "(Canvas.Left)");
AnimateEnemy(enemy, random.Next((int)playArea.ActualHeight = 100), random.Next((int)playArea.ActualHeight = 100), "(Canvas.Top)";

End Sub

End Class

#2 User is offline   AndrewStellman 

  • Andrew Stellman
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 811
  • Joined: 08-October 08
  • Gender:Male
  • Location:Brooklyn, NY
  • Interests:Author of: "Head First C#", "Beautiful Teams", "Head First PMP", "Applied Software Project Management"

Posted 12 May 2014 - 06:01 AM

"Private Sub" and "End Sub" -- that looks like Visual Basic. Have a look at the hand-written note on the upper right-hand corner of page 12:


If your code filenames don’t end in “.cs” you may have accidentally created a JavaScript, Visual Basic, or Visual C++ program. You can fix this by closing the solution and starting over. If you want to keep the project name “Save the Humans,” then you’ll need to delete the previous project folder.

Andrew Stellman
Author, Head First C#
Building Better Software -- http://www.stellman-greene.com

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users