Private Sub Btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn.Click MessageBox.Show("Hey, y'all!") End Sub |
private void btn1_Click(object sender, EventArgs e) { MessageBox.Show("Hey, y'all!"); } // End of btn click procedure. |
/* A really large comment that goes over multiple lines and that has lots of content to read */ |
private void btn1_Click ( object sender, EventArgs e) { MessageBox.Show ("Hey, y'all!"); } // End of btn click procedure. |
private void btn1_Click(object sender, EventArgs e) {MessageBox.Show("Hey, y'all!"); }// End of btn click procedure. |
Private Sub Btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn.Click Dim Bt As Byte, Sh As Short, It As Integer, Lg As Long, Sg As Single, Dbl As Double, Dc As Decimal Dbl = 1.0R 'R after a number makes it a 'real' number, better known as a double-precision floating point. Sg = 2.0F 'F after a number makes the number a float so that it works with other single-precision floating point. Dc = 3D 'D after a number makes the number a decimal so that it works with other decimal types (80-bit non-exponented number). Lg = 4L 'L after number makes number a long so that math works with other longs (64-bit integer) It = 5I 'I makes integers, but since Integer is the default for any number, omitting the I would still have 3 treated as an integer. Sh = 6S 'S after a number makes it a short so that math works with other shorts (16-bit integers) 'S -> I -> L -> D -> F -> R End Sub |
private void btn2_Click(object sender, EventArgs e) { byte bt; short sh; int it; long lg; float sg; double dbl; decimal dc; dbl = 1D; // Use d for doubles vice r for real number. Lowercase d is accepted. sg = 2F; // F and f are fine. dc = 3M; // Use M or m for decimal vice d for doubles. lg = 4L; // I and VS 2010 recommend using L vice l for clarity reasons. it = 5; sh = 4; // Apparently, there are no literals for a short. } // End of btn click procedure. |
private void btn2_Click(object sender, EventArgs e) { float inch, cm; inch = 5; cm = inch * 2.54; } // End of btn 2's click procedure. |
private void btn2_Click(object sender, EventArgs e) { float inch, cm; inch = 5F; cm = inch * 2.54F; // Converts a number of inches to a number of centimeters (centimetres) MessageBox.Show(cm.ToString()); } // End of btn 2's click procedure. |
private void btn2_Click(object sender, EventArgs e) { float fahr, cels; cels = 99.98f; // You get an error if you try to assign 99.98 to 'cels' without the F. fahr = cels * (9 / 5) + 32f; // Converts a number of inches to a number of centimeters (centimetres) MessageBox.Show(fahr.ToString()); } // End of btn 2's click procedure. |
private void btn2_Click(object sender, EventArgs e) { float fahr, cels; cels = 99.98f; // You get an error if you try to assign 99.98 to 'cels' without the F. fahr = cels * (9f / 5f) + 32f; // Converts a number of inches to a number of centimeters (centimetres) MessageBox.Show(fahr.ToString()); } // End of btn 2's click procedure. |
private void btn3_Click(object sender, EventArgs e) { int cents = 546; int dollars, pennies; dollars = cents / 100; // Integer division - cents and 100 are both integers pennies = cents % 100; // % is the modulus in C# MessageBox.Show(String.Format("{0} cents is {1} dollars and {2} pennies.", cents, dollars, pennies)); } // End of btn 2's click procedure. |
private void btn4_Click(object sender, EventArgs e) { string S = tb1.Text.Substring(0, 2); // Returns the first two characters in the textbox. MessageBox.Show(S); // And show them in a messagebox. } // End of btn 3's click procedure. |
private void btn4_Click(object sender, EventArgs e) { string S; if (tb1.TextLength >= 2) { S = tb1.Text.Substring(0, 2); // Returns the first two characters in the textbox. MessageBox.Show(S); // And show them in a messagebox. } // End of if statement for text length of at least 2. } // End of btn 4's click procedure. |
private void btn4_Click(object sender, EventArgs e) { string S; if (tb1.TextLength >= 2) { S = tb1.Text.Substring(0, 2); // Returns the first two characters in the textbox. MessageBox.Show(S); // And show them in a messagebox. } else { MessageBox.Show("Text is too short to display first two characters."); } // End of if statement for text length of at least 2. } // End of btn 4's click procedure. |
private void btn4_Click(object sender, EventArgs e) { string S; if (tb1.TextLength >= 2) { S = tb1.Text.Substring(0, 2); // Returns the first two characters in the textbox. MessageBox.Show(S); // And show them in a messagebox. } else if (tb1.TextLength == 2) { MessageBox.Show(tb1.Text); } else { MessageBox.Show("Text is too short to display first two characters."); } // End of if statement for text length of at least 2. } // End of btn 2's click procedure. |
private void btn4_Click(object sender, EventArgs e) { string S; if (tb1.TextLength >= 2) { S = tb1.Text.Substring(0, 2); // Returns the first two characters in the textbox. MessageBox.Show(S); // And show them in a messagebox. } else if (tb1.TextLength == 2) { MessageBox.Show(tb1.Text); } else if (tb1.Text != "") { MessageBox.Show("Help me out. Put some text in the textbox!"); } else { MessageBox.Show("Text is too short to display first two characters."); } // End of if statement for text length of at least 2. } // End of btn 4's click procedure. |