Monday, January 31, 2011

If Statements

This is a example of a If statement.
  Dim name, correct As String  
     name = "Dalonte"  
     If name = "Dalonte" Then  
       correct = "Yes"  
     End If  
     MessageBox.Show(correct)  

I just basically give name a value and put it in a if statement saying if name = the name i put in then it would output Yes.

This is a example of a If statment where its either or
  Dim name, correct As String  
     name = "Gibson"  
     If name = "Dalonte" Then  
       correct = "yes"  
     Else  
       correct = "no"  
     End If  
     MessageBox.Show(correct)  
This is just like my example above but the only thing i did different is that i added a "ELSE" so that if the name does not match up it was say no

This is a example of a if statement where many decisions are made
  Dim name, As String  
     name = "anderson"  
     If name = "Dalonte" Then  
       MessageBox.Show("First Name")  
     ElseIf name = "Gibson" Then  
       MessageBox.Show("last name")  
     ElseIf name = "anderson" Then  
       MessageBox.Show("Middle Name")  
     End If  
The only thing that i did different on this one is that i added a elseif statement which allows me to make more then 2 decisions.

This is a example of a case statement
 Select [ Case ] testexpression  
   [ Case expressionlist  
     [ statements ] ]  
   [ Case Else  
     [ elsestatements ] ]  
 End Select  

1st you have to make a Select case statement, then from there you can make as many cases as you want followed by a end Select

Friday, January 28, 2011

How to join a String with another String

  Dim FirstName As String  
     Dim LastName As String  
     Dim FullName As String  
     FirstName = "Bill"  
     LastName = "Gates"  
     FullName = FirstName & LastName  
     MessageBox.Show(FullName)  

first you have to declare your variables then you have to give each variable a value such as Bill and Gates. From there you add them together with a "&" sign then display it with a messagebox

Monday, January 24, 2011

How to set variables

This is how you set the following variables: String, Integer, Decimal

 Public Class Form1  
   Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click  
     Dim FirstName As String  
     Dim Age As Integer  
     Dim GPA As Decimal  
     Dim Result As DialogResult  
     FirstName = "Dalonte"  
     Age = "22"  
     GPA = "3.6"  
     Result = MessageBox.Show(FirstName & Age & GPA)  
   End Sub  
 End Class  

The Integer data type provides optimal performance on a 32-bit processor. The other integral types are slower to load and store from and to memory.

The Decimal data type provides the greatest number of significant digits for a number. It supports up to 29 significant digits and can represent values in excess of 7.9228 x 10^28. It is particularly suitable for calculations, such as financial, that require a large number of digits but cannot tolerate rounding errors.

The default value of Decimal is 0.

Use the String data type to hold multiple characters without the array management overhead of Char(), an array of Char elements.

The default value of String is Nothing (a null reference). Note that this is not the same as the empty string (value "").

The default value of Integer is 0.

This is how you set a Boolean variable:

 Dim runningVB As Boolean  
 ' Check to see if program is running on Visual Basic engine.  
 If scriptEngine = "VB" Then  
   runningVB = True  
 End If  

Use the Boolean data type to contain two-state values such as true/false, yes/no, or on/off.

The default value of Boolean is False.

When Visual Basic converts numeric data type values to Boolean, 0 becomes False and all other values become True. When Visual Basic converts Boolean values to numeric types, False becomes 0 and True becomes -1.


This is how to convert a number variable into a string

 Dim int As Integer = 789  
 Dim str As String = int.ToString()  
 str now holds 789 as a string.  

you start by declaring a int, then after you do that you have to declare a string = int.ToString()
so that what ever value you entered for your int will also be = to your string variable.

This is how you convert a int into a decimal

 Dim d=132.31223 as Double  

This is easy all you have to do is that when you declare your int follow it by as Double

This is how you join two strings

 Dim FirstName As String  
 Dim LastName As String  
 Dim FullName As String  
 FirstName = "Bill"  
 LastName = "Gates"  
 FullName = FirstName & LastName  
 Textbox1.Text = FullName  

For this one all you have to is declare to string and give them both a value. This declare another variable witch will be use to join them. Once you declare another string to add the other two you have to = is to String1 & String2

Wednesday, January 19, 2011

Repeatable Process examples

Calculate the final grade

30% Blog 40% assignments 10% peer evals 20% final

86/100 Blog, 345/450 assignment, 43/50 peer, 55/80 final

BlogTP = 100
BlogS = 86 86/100 x .3 = 23.8
BlogW = .3
BlogP = BlogS/BlogTP


AssignTP = 450
AssignS = 345
AssignP = AssignS/AssignTP(76.7) x .4 = 30.68

Grade = (BlogP x BlogW) + (AssignP x AssignW)

Tuesday, January 18, 2011

Content place holder

Content place holder is the part of the website that changes, then from there is defined by a content page. Here is some example code:


 <%-- ContentPlaceHolder control --%>  
 <asp:contentplaceholder id="FlowerText" runat="server"/>  
 <%-- ContentPlaceHolder with default content --%>  
 <asp:contentplaceholder id="FlowerText" runat="server">  
  <h3>Welcome to my florist website!</h3>  
 </asp:contentplaceholder>  

Content Page

A content page is the part of the website that changes every time you go to a different page of the website. Content pages define the content place holders. Some example code is:

 <%@ Page MasterPageFile="Site.master" %>  
 <asp:content id="Content1" contentplaceholderid="FlowerText" runat="server">  
   With sunshine, water, and careful tending, roses will bloom several times in a season.  
 </asp:content>  
 <asp:content id="Content2" contentplaceholderid="FlowerPicture" runat="server">  
   <asp:Image id="image1" imageurl="~/images/rose.jpg" runat="server"/>  
 </asp:content>  

The contentplaceholderid lets you know what place holder you are working with at the time.

Master Page

Master page is basically a template page that you see on every page of the web site. Here is some example code:



 <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>   
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  <html xmlns="http://www.w3.org/1999/xhtml">  
  <head runat="server">   
 <title>Untitled Page</title> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head>   
 <body> <form id="form1" runat="server"> <div> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form> </body> </html>   

Create Web Project

Step:
          1) Go to file and click new web site
          2) At the bottom name the file then click on OK

Friday, January 14, 2011

Name: Message Box
Description: Making a message box

 MessageBox.Show("Hello World!")