1 / 12

Adding Controls for Document Properties and Mathematical Functions in Lab 6 and 7

This document outlines the process of adding controls in Lab 6 and 7 for manipulating document properties. The program includes functions for temperature conversion between Celsius and Fahrenheit, squaring numbers, calculating square roots, and generating random numbers. It incorporates input validation to ensure that the entered values are numeric and within the required limits. It also demonstrates the use of random number generation and the implications of statistical outcomes in practical applications, such as flipping a coin multiple times.

yitta
Télécharger la présentation

Adding Controls for Document Properties and Mathematical Functions in Lab 6 and 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Labs 6 and 7

  2. Adding “Controls” to a Document

  3. Properties

  4. Code! Celsius: TextBox2.Text = (TextBox1.Text - 32) * (5 / 9) Fahrenheit: TextBox2.Text = (TextBox1.Text) * (9 / 5) + 32 Squared: TextBox2.Text = (TextBox1.Text) ^ 2 Square Root: TextBox2.Text = Sqr(TextBox1.Text) Random (Lab 7): TextBox2.Text = Rnd( )

  5. Better If IsNumeric(TextBox1.Text) Then TextBox2.Text = (TextBox1.Text - 32) * (5 / 9) Else TextBox2.Text = "Not a number" End If

  6. Square Root – two IFs If IsNumeric(TextBox1.Text) Then If (TextBox1.Text >= 0) Then TextBox2.Text = Sqr(TextBox1.Text) Else TextBox2.Text = "Must be positive" End If Else TextBox2.Text = "Not a number" End If

  7. Random Numbers Rnd ( ) gives a random floating point number between 0 and 1 Int ( ) converts a floating point number to an integer by truncating the whole part 1.5672 becomes 1 Int( 2 * Rnd( ) ) will give us random 0s and 1s

  8. The Princeton Egg Project http://www.redorbit.com/news/science/126649/can_this_black_box_see_into_the_future/ http://noosphere.princeton.edu/tapestry.html

  9. What does that mean for us If you flip a coin (1= heads, 0 = tails) 1000 times, The results should always be very close to 50% 1s and 50% 0s If it’s not, then tragedy looms

  10. If IsNumeric(TextBox1.Text) Then If (TextBox1.Text >= 0) Then TextBox2.Text = 0 X = 0 While ( X < Int(TextBox1.Text) ) TextBox2.Text = Int(2 * Rnd()) + Int(TextBox2.Text) X = X + 1 Wend Else TextBox2.Text = "Must be positive" End If Else TextBox2.Text = "Not a number" End If

More Related