Thursday, February 17, 2011

VB Programming / XML

Been sharpening my VB skills up this week, and revisiting code of the past and present!
Hopefully I have some big things in store for me!
It seems every book, instructor, and course has different information of whatever subject matter is relevant,
and important.
Which begs the question , What exactly is?
Well, all of it!!!
I don't mind because I learn a range of things, but just find it interesting enough to mention!

Here is an exercise from:

by Jerry Lee Ford, Jr.
here is a link for inexpensive purchase:
http://search.barnesandnoble.com/Microsoft-Visual-Basic-2008-Express-Programming-for-the-Absolute-Beginner/Jr-Jerry-Lee-Ford-Jerry-Lee/e/9781598639001

So the exercise starts of in MenuBar creation, and moves in to loops and conditions...
I went through it and added comments from the text and my own, with easy formatting to explain each sections purpose...
The program is designed to ask for lottery numbers, and picks, and then generates a sample for you...

Here is the "Beast" of the code:

Public Class ltaForm

    Private Sub GetNumbersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetNumbersToolStripMenuItem.Click

        'Statements that are to be executed when the Get Numbers menu item is clicked between these two statements
        'These statements define variables and an array used by the application to store and manipulate the data it needs to execute
        Dim intForLoopCtr As Integer = 0
        Dim blnFullSetComplete As Boolean = False
        Dim intRndNo As Integer = 0
        Dim strDisplayString As String = ""
        Dim intNoOfValidPics As Integer = 0
        Dim aintLotteryArray(10) As Array
        Dim intNumberCount As Integer = 0
        Dim strTestString As String = "_"

        'These statements check to see if the player has supplied valid input into the first TextBox control
        'and displays an error message if this is not the case

        If txtFullSet.Text = "" Then
            MessageBox.Show("You must specify how many numbers " & _
            "make up a full set.")
            Return
        End If

        'The next set of statements checks to ensure that that the player entered numeric data into the first TextBox control
        'and displays an error message if this is not the case
        If IsNumeric(txtFullSet.Text) = False Then
            MessageBox.Show("You must specify numeric input when " & _
            "specifying how many numbers make up a full set.")
            Return
        End If

        'The next set of statements to be added check to see if the player entered a number greater than 10 in the first TextBox control
        'and displays an error message if this is the case
        If Int32.Parse(txtFullSet.Text) = 10 Then
            MessageBox.Show("The maximum number of numbers in a full " & _
                           "set is 10. Please enter a number between 3 - 10.")
            Return
        End If

        'The following statements check to make sure that the user specified a number of no less than 3 in the first TextBox control
        If Int32.Parse(txtFullSet.Text) < 3 Then
            MessageBox.Show("The minimum number of numbers in a full " & _
                            "set is 3. Please enter a number between 3 - 10.")
            Return
        End If

        'These statements display error messages if the player fails to supply any text, if the player does not supply numeric input
        'or if the player tries to specify a number less than 1 or greater than 10 in the second text box

        If txtNoPics.Text = "" Then
            MessageBox.Show("You must specify how many sets of " & _
                            "Lottery numbers you want.")
            Return
        End If

        If IsNumeric(txtNoPics.Text) = False Then
            MessageBox.Show("You must specify numeric input when " & _
                            "specifying how many sets of lottary numbers you want.")
            Return
        End If

        If Int32.Parse(txtNoPics.Text) > 10 Then
            MessageBox.Show("The maximum number of lottery tickets " & _
                            "that can be generated is 10. Please enter a number " & _
                            "between 1 - 10.")
            Return
        End If

        If Int32.Parse(txtNoPics.Text) < 1 Then
            MessageBox.Show("The minimum number of lottery tickets " & _
                            "That can be generated is 1. Please enter a number " & _
                            "between 1 - 10.")
            Return
        End If

        'Program statements that validate the contents of the third TextBox control

        'Display error messages if the player fails to supply any text, if the player does not supply numeric input
        'or if the player tries to specify a number that is less than 9 or greater than 50

        If txtNoRange.Text = "" Then
            MessageBox.Show("You must specify the highest number " & _
                            "that can be picked.")
            Return
        End If

        If IsNumeric(txtNoRange.Text) = False Then
            MessageBox.Show("You must specify numeric input when " & _
                            "specifying the highest number that can be picked.")
            Return
        End If

        If Int32.Parse(txtNoRange.Text) > 50 Then
            MessageBox.Show("The maximum value for the highest number " & _
                            "is 50. Please enter a number " & _
                            "less than or equal to 50.")
            Return
        End If

        If Int32.Parse(txtNoRange.Text) < 9 Then
            MessageBox.Show("The minimum value for the highest number " & _
                            "that can be picked is 9. Please enter a number " & _
                            "greater than or equal to 9.")
            Return
        End If



        'The For loop executes once for each set of lottery numbers that the player wants generated
        'The Do loop executes repeatedly until a complete set of numbers has been generated

        For intForLoopCtr = 1 To CInt(txtNoPics.Text)

            Do Until blnFullSetComplete = True
                Randomize()

                intRndNo = _
                 FormatNumber(Int((txtNoRange.Text * Rnd()) + 1))

                If InStr(strTestString, _
                Convert.ToString("_" & intRndNo & "_")) = 0 Then
                    strDisplayString = strDisplayString & " " & _
                    intRndNo & ControlChars.Tab
                    intNoOfValidPics = intNoOfValidPics + 1
                    strTestString = strTestString & intRndNo & "_"
                End If

                If intNoOfValidPics = Int32.Parse(txtFullSet.Text) Then
                    blnFullSetComplete = True

                    strDisplayString = strDisplayString & _
                    ControlChars.NewLine & ControlChars.NewLine
                    strTestString = "_"
                End If
            Loop

            blnFullSetComplete = False
            intNoOfValidPics = 0

        Next


        'The basic logic used in the statements wrapped inside the Do loop is as follows:
        '1) Get a randomly generated number.
        '2) Add that number to a string representing a list of lottery numbers
        'but don’t allow duplicate numbers to be added to the list.
        '3) Format the display string so that a new line is generated for each set of lottery numbers.



        'The last program statements added to the code that executes in response to the Get Numbers menu item’s click event is shown here:

        txtOutput.Text = strDisplayString
        GetNumbersToolStripMenuItem.Enabled = False
        ClearNumbersToolStripMenuItem.Enabled = True
    End Sub
    Private Sub ClearNumbersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearNumbersToolStripMenuItem.Click

        'The first four statements clear out any text displayed in the four TextBox controls.
        'The next statement places the cursor in the first TextBox control,
        'and the last two statements enable the Get Numbers menu item and disable the Clear Numbers menu item

        txtFullSet.Text = ""
        txtNoPics.Text = ""
        txtNoRange.Text = ""
        txtOutput.Text = ""
        txtFullSet.Focus()
        GetNumbersToolStripMenuItem.Enabled = True
        ClearNumbersToolStripMenuItem.Enabled = False
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender _
          As System.Object, ByVal e As System.EventArgs) _
          Handles ExitToolStripMenuItem.Click
        Application.Exit()

    End Sub

    Private Sub WhiteToolStripMenuItem_Click(ByVal sender _
      As System.Object, ByVal e As System.EventArgs) _
      Handles WhiteToolStripMenuItem.Click
        'Menu item white background color
        Me.BackColor = Color.White
        WhiteToolStripMenuItem.Checked = True
        YellowToolStripMenuItem.Checked = False
        GrayToolStripMenuItem.Checked = False

    End Sub


    Private Sub YellowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YellowToolStripMenuItem.Click
        'Menu item yellow background color
        Me.BackColor = Color.Yellow
        WhiteToolStripMenuItem.Checked = False
        YellowToolStripMenuItem.Checked = True
        GrayToolStripMenuItem.Checked = False

    End Sub


    Private Sub GrayToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GrayToolStripMenuItem.Click
        'Menu item gray background color
        Me.BackColor = Color.LightGray
        WhiteToolStripMenuItem.Checked = False
        YellowToolStripMenuItem.Checked = False
        GrayToolStripMenuItem.Checked = True

    End Sub


    Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
        'Makes fornt 8pt Microsoft Sans Serif
        txtOutput.Font = New Font("Microsoft Sans Serif", 8)
        ToolStripMenuItem1.Checked = True
        ToolStripMenuItem1.Checked = False
        ToolStripMenuItem2.Checked = False

    End Sub


    Private Sub ToolStripMenuItem2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
        ''Makes fornt 10pt Microsoft Sans Serif
        txtOutput.Font = New Font("Microsoft Sans Serif", 10)
        ToolStripMenuItem1.Checked = False
        ToolStripMenuItem2.Checked = True
        ToolStripMenuItem3.Checked = False

    End Sub


    Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
        'Makes fornt 12pt Microsoft Sans Serif
        txtOutput.Font = New Font("Microsoft Sans Serif", 12)
        ToolStripMenuItem1.Checked = False
        ToolStripMenuItem2.Checked = False
        ToolStripMenuItem3.Checked = True

    End Sub


    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        MessageBox.Show("This Visual Basic application was created " & _
        "by Jerry Lee Ford, Jr. " & _
        "This code was hand entered, and comments placed and formatted " & _
        "by Andrew Garbe for practice and learning purposes.")
    End Sub
End Class


Got that?

I am entering in to the realm of XML tags next.
we are brushing on a few topics in my Database class such as:
-Datawarehouses
-Datamining
-Cookie Algorithms
and XML...

So, I will be sure to add some of my newly discovered XML tags and projects!

-A

Thursday, February 10, 2011

Google Salesforce and Chrome

It has been a while since I have posted.
Been very busy in SQL server and Management Information Systems classes.
Also a XBOX360 and new TV hasn't helped my spare time!

A good friend has been a strong advocate for Google's technology,
so I have cleared this morning to familiarize myself with Google's applications...


1st on the docket is Salesforce.

Salesforce is a cloud based business management tool, here is a link... https://www.salesforce.com/crm/editions-pricing.jsp
You can download a free trial to give it a spin

Next on the agenda is the Google Chrome Web browser

So far my take is, very minimal in design,
which leads me to believe it won't need to update as much as let's say Mozilla...
Once again, here is a link to download this browser:
http://www.google.com/chrome

I have been learning cool concepts lately in SQL about database creating and query's,
as well as data mining, and tracking cookie algorithms...

Until the next post!
-A

Thursday, December 30, 2010

DreamWeaver CS5 / Medicine Ball Exercise

I was going to wait until the new year to start getting busy here on this blog, but why wait!
I just got a medicine ball I ordered yesterday, and am ready to get busy using it...
Also, Peggy got me a new camera for xmas,
so there will be a lot more picture here in the future!


Here are a few exercises I picked up if you feel so inclined:
Men's Health  December 2010 issue

Medicine Ball Twist - Hold a medicine ball at chest level, arms straight out. Without moving your torso, rotate your arms far to the left, than far to the right. That's 1 rep.
Continue back and forth as fast as you can.

Mountain Climber- Assume a push up position with your hands on a medicine ball. Lift your right foot off the floor and raise your right knee as close to your chest as you can, without rounding your lower back. Put your leg down and repeat with your left leg.
Continue alternating as fast as you can.

Medicine Ball Slam - Hold a medicine ball at waist level, and stand with your feet shoulder-width apart. While keeping your elbows slightly bent, explosively lift the ball up and slam it to the floor in front of you. Grab the ball on the rebound and repeat.

Here are some youtube link to some videos as well:
http://www.youtube.com/watch?v=cZvrFK8y7NE&feature=related
http://www.youtube.com/watch?v=CDEhekunkj4


Adobe DreamWeaver CS5
I have also been studying DreamWeaver CS5 for Web application.
http://tryit.adobe.com/us/cs5/dreamweaver/tw1/?sdid=IBERS

I really like my experience with Adobe products, and am enjoying this one as well! DreamWeaver allows you to create, even from preloaded templates, websites and pages without knowing HTML and CSS.
I am studying with a Lynda.com tutorial video that shows you how to work DreamWeaver and create as well as adjust code and understand it...
Here is a link to that tutorial video:
http://www.lynda.com/home/DisplayCourse.aspx?lpk2=58712
Hope some of this helps! I look forward to reading this back in the future and laughing at when I just got started!
-A

Wednesday, December 22, 2010

mySQL / Microsoft SQL server / Visual Studio 2010

Well almost the end of the year.
I am satisfied with my goals,
but really want to kick it into high gear in 2011...

I have classes in SQL this quarter and am looking to expand on what is presented.
I downloaded mySQL and installed...
Here is a link and also a link to a very helpful tutorial to get started:
mySQL: http://www.mysql.com/
mySQL tutorial: http://www.lynda.com/home/DisplayCourse.aspx?lpk2=770

My class is in Microsoft SQL Server 2008 which can be downloaded from Dreamspark as a student with a valid .edu email...


To day I am going to post a exercise on how to make a Splash Screen in Microsoft Visual Basic...
This exercise is from the book:
Microsoft Visual Basic 2008 Express Programming for the Absolute Beginner by Jerry Lee Ford, Jr.
( It is proving to be a very helpful book! You should get it or subscribe to books 24/7 )

Adding a Splash Screen to Your Application

One thing that you might want to do to spice up your application is to give it a splash screen. The IDE makes the creation and setup of a splash screen very straightforward. All that you have to do is create a new form and then tell the IDE to make it your application’s splash screen.

Definition 

A splash screen is a window that appears briefly when an application first loads. Application developers use splash screens to display product information or to distract users while their application loads.
The following example demonstrates the steps involved in adding a splash screen to your Visual Basic applications.
  1. Open a new Visual Basic Windows application project, and expand the default form to approximately twice its normal size to make it distinguishable from its splash screen. Place whatever controls you want on it.
  2. Click on the Project menu and select the Add Windows Form option.
  3.   Select the Splash Screen and click on the Add button. A window named SplashScreen1 is added to the project.
  4. The IDE will display the SplashScreen1 form. At this point you may add a Label control to the form and specify whatever text you want to have displayed. Optionally, you may add a PictureBox control to display a graphic. Visual Basic will automatically display text on the splash screen form representing your application’s name, version, and copyright date. You do not need to modify this information. Visual Basic will supply this information for you.
  5. Click on the Properties option located at the bottom on the Project menu. A new window will appear in the IDE.
  6. Make sure that the Application tab is displayed.
     
    Configuring a Visual Basic application to begin by displaying a splash screen.
  7. Using the Splash screen drop-down list at the bottom of the window, select SplashScreen1 as your application’s splash screen.
Now, close the Properties window and press F5 to run your application. Just before the main menu starts, you should briefly see your splash screen appear. After a moment, it will close and your application’s main window will be displayed.


 A splash screen gives the application developer a chance to share additional information with the user before the application starts.

The application’s main window appears as soon as the splash screen closes.

Happy Holidays!
-A 

Wednesday, December 1, 2010

Visual Studio Development - Village Anchor

I haven't posted in awhile...Been Busy Busy!
Just finished my Microsoft Office and XHTML courses,
should have an A in both classes!

I am exploring all the Microsoft content and trying to update on DreamSpark...
https://www.dreamspark.com/default.aspx

Just loaded up all the Visual Studio 2010 content and am going through lynda.com new tutorials...
http://www.lynda.com/home/DisplayCourse.aspx?lpk2=67159

I am also wanting to get a Windows 7 phone eventually and learn how to develop apps for it...
I need to learn XAML first, the markup language of the phone...

Also a new restaurant we  recently tried and was Awesome is the Village Anchor:
http://www.villageanchor.com/

Wednesday, November 10, 2010

Visual Basic button click game

I had mentioned previously that Peggy and I were working on getting out more and not being home bodies.
This past week we had met up with some folks from her softball team an played laser tag at lazerblaze in St. Matthews...
http://www.lazerblaze.com/
It was pretty awesome,
I haven't been since I was younger...
Good Times!

We also went out and ate at Dakshin which is very tasty!
www.mydakshin.com/



The menu is vast and stretches India through Indo-Chinese dishes...


Visual Basic game project
A knowledge creating forms, buttons, and text-boxes, as well as naming properties is helpful before proceeding...
The bulk of my post here to add reference of a project in a book I have been working out of:

Microsoft Visual Basic 2008 Express Programming for the Absolute Beginner 
by Jerry Lee Ford, Jr.

Here is a button click game code from that book that can help you practice your skills at creating a program in VB

Step 1: Creating a New Visual Basic Project

The first step in creating the Click Race game is to start Visual Basic and open a new Windows Forms Application project.
  1. If you have not already done so, start up Visual Basic 2008 Express and then click on File and select New Project. The New Project dialog will appear.
  2. Click on the Windows Form Application icon.
  3. Next, type Click Race as the name of your new application in the Name field located at the bottom of the New Project window.
  4. Click on OK to close the New Project dialog.
Visual Basic will now create a new project, including an initial form, in its IDE.

Step 2: Creating the User Interface

  Now it is time to add the controls required to assemble the game’s interface. The overall layout of the game’s interface is shown in Figure 2.29.
Image from book
Figure 2.29: Completing the interface design for the Click Race game.
  1. Let’s begin by adding a TextBox to the form. By default, Visual Basic assigns the name Textbox1 to the control.
  2. Then let’s add a Label, which Visual Basic automatically names Label1, to the form.
  3. Move and resize TextBox1 and Label1 to the approximate location shown in Figure 2.29.
  4. Add the first button to the form and place it in the lower-left corner. Visual Basic assigns it the name Button1.
  5. Add the second button to the lower-right corner. Visual Basic assigns it the name Button2.

     
     
    It is important that you not get the buttons mixed up. You will need to know which button is which when it is time to begin adding code to the application.
  6. Then add the third button to the upper-right corner of the form. Visual Basic assigns it the name Button3.
  7. Next, add a fourth button just beneath it. Visual Basic assigns it the name Button4.
  8. Finally, add a Timer control to your form, which Visual Basic names Timer1. Since the user doesn’t interact directly with the timer, the Timer1 control is displayed in the component tray rather than on the main form.
The layout and design of your Visual Basic form is now complete and should look like the example shown in Figure 2.29, except that the Timer1 control is displayed in a component tray just below the form.

Step 3: Customizing Form and Control Properties

  Before you start customizing the properties associated with the controls that you just added to the form, let’s change one of the properties belonging to the form itself. Specifically, let’s modify the form so that it displays the text string of Click Race Game in its title bar. To do this, click anywhere on the form, except on top of one of its controls, and then locate the Text property in the Properties window and replace the default value of Form1 with Click Race Game.
The first control to modify is the Textbox1 control. Table 2.3 lists all of the properties that you should modify and shows what their new values should be.
 
Table 2.3: Property Changes for the Textbox 1 Control Open table as spreadsheet
Property
Value
  BackColor
  Info
  ForeColor
  HotTrack (on the System Tab)
  ReadOnly
  True
  Font
  Arial
  Font
  Regular
  Font
  Size 14
  Size
  132, 29
Once you have completed making the property changes for the TextBox1 control, let’s work on the Label1 control by making the property changes shown in Table 2.4.
 
Table 2.4: Property Changes for the label 1 Control Open table as spreadsheet
Add a note hereProperty
Add a note hereValue
  Font
  Arial
  Font
  Bold
  Font
  Size 12
  Text
  Number of Clicks
Now, referring to Table 2.5, modify the properties associated with Button1, Button2, Button3, and Button4.
 
Table 2.5: Property Changes for the Button Controls Open table as spreadsheet
Button Name
Property
Value
  Button1
  Text
  Click Me!
 
  Font
  Arial
 
Font
Regular
 
Font
  Size 9
  Button2
  Text
  Click Me!
 
  Font
  Arial
 
  Font
  Regular
 
  Font
  Size 9
  Button3
  Text
  Start Game
 
  Font
  Arial
 
  Font
Regular
 
  Font
  Size 9
  Button4
  Text
  Exit
 
  Font
  Arial
 
  Font
  Regular
 
  Font
  Size 9
There is one last property modification that needs to be made. It is to the Timer1 control located in the component tray. By default, the Timer1 control’s Interval property is set to 100 by Visual Basic at design time. Interval represents the amount of time in milliseconds that passes during each interval measured by the Timer control. It is a lot easier for people to think in terms of seconds than in terms of milliseconds. So let’s change the value assigned to Interval1 to 1000 as shown in Table 2.6.
 
Table 2.6: Property Changes for the Timer 1 Control Open table as spreadsheet
Property
Value
  Interval
1000
That’s all the property modifications that are required for the Click Race game. Now it is time to give life to the application by adding the programming code that will make the game run.

Step 4: Adding a Little Programming Logic

  Okay, it is time to start coding. If you double-click on Form1, Visual Basic starts things off for you by adding a number of lines of code, as shown next. Actually, what you’ll see in the code editor window is slightly different from what you see here. Take a look at the end of the second line of code shown below. Notice that it ends with the underscore character. In Visual Basic, the underscore character is used as a continuation character. I added it where I did so that I could make the code statement a little easier to read by breaking it out into two lines. Other than this cosmetic change, everything else is exactly the same.
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

End Class
Visual Basic 2008 Express is an OOP (object-oriented programming) language. In order to work with an object, you must define an instance of the object in your application. In the case of the above code, in the first statement, Visual Basic defines an object named Form1 on your behalf, which extracts everything it needs from the Visual Basic Class Library. All code for the Form1 object or any of the controls that you have added to the form is placed somewhere after the Public Class Form1 statement and before the closing End Class statement. These two statements define the beginning and end of the code affecting the Form1 object.


 
In between the Public Class Form1 statement and the End Class statement are two more statements. These statements identify the beginning and end of the Form1_Load event procedure. Take a look at the first of these two statements and you will see that the first statement assigns the procedure the name Form1_Load. You can change the name of the procedure to anything that makes sense to you.
The Load keyword refers to the form’s Load event. Events occur in Visual Basic whenever something happens. For example, when a form first appears or loads, the Load event for that form executes. Therefore, this procedure executes when the application starts (for example, when the form first loads). Don’t worry if this explanation is a little difficult to grasp just yet. I shared it with you now just to try to give you a feel for what Visual Basic is doing. I’ll go over procedures and events in much more detail in later chapters.
  Now it is time to begin adding code to the Click Race game. Again, since you won’t start learning how to formulate Visual Basic statements until Chapter 4, “Working with Menus and Toolbars,” just follow along and make sure that you enter any Visual Basic statements exactly as I’ll show you.
For starters, add the two statements shown below in bold exactly where shown. These statements define two variables that the application will use to keep track of how many times the player has clicked on the game’s buttons and how long the game has been running.
Public Class Form1

    Dim intCounter As Integer = 0
    Dim intTimerCount As Integer = 0

    Private Sub Form1_Load(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

End Class
Next, add the two statements shown below in bold in the Form1_Load procedure. These statements execute as soon as the form loads and gray out the two buttons used to play the game.
Public Class Form1

    Dim intCounter As Integer = 0
    Dim intTimerCount As Integer = 0

    Private Sub Form1_Load(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles MyBase.Load

        Button1.Enabled = False
        Button2.Enabled = False

    End Sub

End Class
  Now click on the Form1.vb [Design] tab to return to the designer view and then double-click on Button1. This switches you right back to the code editor, where you will see that Visual Basic has added a new procedure named Button1_Click. Add the four statements shown below in bold to this procedure exactly as shown. The first statement adds a value of 1 to the intCounter variable, which the game uses to track the total number of mouse clicks made by the player. The second statement displays the value of intCounter in the Textbox1 control so that the player will know that a click has been counted. The next two statements gray out or disable Button1 and enable Button2 (because the game forces the player to alternate the clicking of these two buttons).
Private Sub Button1_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button1.Click

    intCounter = intCounter + 1
    TextBox1.Text = intCounter
    Button1.Enabled = False
    Button2.Enabled = True

End Sub
Now click on the Form1.vb [Design] tab to return to the designer view and then double-click on Button2. This switches you back to the code editor. You’ll notice that Visual Basic has added a new procedure named Button2_Click. Add the four statements shown below in bold to this procedure. As you can see, these statements look almost exactly like the four statements that you added to the previous procedure, except that the last two statements switch the enabling and disabling of the two game buttons.
 Private Sub Button2_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button2.Click

    intCounter = intCounter + 1
    TextBox1.Text = intCounter
    Button1.Enabled = True
    Button2.Enabled = False

End Sub
Now it is time to add some code to the game’s Start button (Button3). Start by clicking on the Form1.vb [Design] tab to return to the designer view and then double-click on Button3. This switches you back to the code editor. You’ll notice that Visual Basic has added a new procedure named Button3_Click. Add the six statements exactly as shown below to this procedure. This procedure is used to start or restart the game at any time. The first two statements reset the values assigned to the game’s two variables back to zero. The next statement clears out Textbox1. Two statements that follow enable Button1 and disable Button2. The last statement restarts the Timer1 control.
Private Sub Button3_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button3.Click

    intCounter = 0
    intTimerCount = 0
    TextBox1.Text = ""
    Button1.Enabled = True
    Button2.Enabled = False
    Timer1.Enabled = True

End Sub
Now let’s fix up the Exit button (Button4) so that it will close the Click Race game when the player clicks on it. Click on the Form1.vb [Design] tab to return to the designer view and then double-click on Button3. This switches you back to the code editor, where you’ll see that Visual Basic has added a new procedure named Button4_Click. Add the following statement to it, shown in bold, exactly as shown next. This statement tells Visual Basic to exit the application.
Private Sub Button4_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button4.Click

    Application.Exit

End Sub
Now all that is left to do is to add some code to the Timer1 control so that it will limit the player’s turn to 30 seconds. Click on the Form1.vb [Design] tab to return to the designer view. Double-click on Timer1. Visual Basic automatically adds the Timer1_Tick procedure to your application. Add the five Visual Basic statements shown below in bold to this procedure. The first statement tells the Timer1 control to keep track of the number of seconds that it has run. Remember that you previously configured the Timer1 object’s Interval property so that the Timer1 control would execute every second. The next four statements will execute as soon as the Timer1 control has run for 30 seconds, at which time the two game buttons will be disabled, thus ending the player’s turn.
Private Sub Timer1_Tick(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Timer1.Tick

    intTimerCount = intTimerCount + 1
    If intTimerCount = 30 Then
      Button1.Enabled = False
      Button2.Enabled = False
    End If

End Sub
 
click F5 or run and check your work!

Wednesday, November 3, 2010

Get up and out!

 New Goal
I have been like a mad scientist working in the lab!
The goal of this whole blog was to keep me motivated and on point focused on my goals,
which I have been more focused on different aspects at times,
but the main goal is being achieved...
So, what next?
I need to get out more!
Peggy and I are so busy and have our hobbies and studies and of course work which consumes a lot of time...
I had mentioned to her that we need to go see more shows (music - comedy - sports- etc)
So that will be a new source of material I hope to add here...
Also here are some new nuggets of info for ya:

New Restaurant we tried recently...
http://www.limestonerestaurant.com/

These are some photos from their website.
We had the "feed me light" with wine pairings (3 courses)
It was very tasty!










New Math tutorial page I have found a little helpful for trigonometry exercises:
http://www.clarku.edu/~djoyce/trig/

I have also been plugging away at Visual Basic game exercises and tables in XHTML...
I might start putting those codes up here in the future, well see!

-A