Jump to content


Photo

Save The Humans


  • Please log in to reply
1 reply to this topic

#1 Jason Vearing

Jason Vearing

    New Member

  • Members
  • Pip
  • 1 posts

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)
AddEnemy();
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)";
playArea.Children.Add(enemy);


End Sub

End Class

#2 AndrewStellman

AndrewStellman

    Andrew Stellman

  • O'Reilly Author
  • PipPipPipPipPipPipPipPipPipPipPip
  • 826 posts
  • 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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users