Thursday, September 2, 2010

Thursday, September 2nd

Hi!

Today I am going to be looking at Michael Halvorson's tutorials, which are excellent so far. They are low-key and fun, which is really helpful. You read a short bio here if you wish.

The first tutorial is about using loops and timers.

Let's take a look at the syntax for a for loop


For variable = start to end
statements go here
Next [variable]


The first example Michael Halvorson gives is


Dim i As Integer
For i = 1 To 4
Beep()
Next i


I changed it to


Dim i As Integer
Dim CounterVariable As Integer
CounterVariable = 5
For i = 1 To CounterVariable
beep()
Next i


I then fooled around with it a bit more and created


Dim i As Integer
Dim CounterVariable As Integer
CounterVariable = 5
For i = 1 To CounterVariable
System.Console.Beep(200, 200)
Next i


I then wanted to disable the button while the beeps where playing



Enabled = False
Dim i As Integer
Dim CounterVariable As Integer
CounterVariable = 5
For i = 1 To CounterVariable
System.Console.Beep(200, 200)
Next i
Enabled = True



I then created a textbox so the user could define the number of times to beep and threw in some simple data validation


Dim NumberOfTimes As Integer
NumberOfTimes = Convert.ToInt32(txtNumberOfTimes.Text)
If NumberOfTimes < 20 Then
Enabled = False
Dim i As Integer
Dim CounterVariable As Integer
CounterVariable = txtNumberOfTimes.Text
For i = 1 To CounterVariable
System.Console.Beep(200, 200)
Next i
Enabled = True
Else
MessageBox.Show("That number is too high!")
End If


As with all of my personal projects i went beyond my ability limited by my lack of training and inexperience and didn't get quite what i wanted, but that's OK. Tomorrow I will do more tutorials.


Dim pitch As Integer
pitch = 200

Dim pitchLoopCounter As Integer
pitchLoopCounter = 0



Dim pitchUp As Boolean
pitchUp = True


Dim pitchLoopCounterMod As Double




Dim NumberOfTimes As Integer
If Not IsNumeric(txtNumberOfTimes.Text) Then
MessageBox.Show("Please be so kind as to enter a number.", "Holy tamole")
Exit Sub
Else
NumberOfTimes = Convert.ToInt32(txtNumberOfTimes.Text)
End If

If NumberOfTimes < 35 Then
btnBeepIt.Enabled = False

Dim i As Integer

i = 0

Do
txtLoopCounter.Text = pitchLoopCounter

System.Console.Beep(pitch, 200)

i += 1
pitchLoopCounter += 1

If pitchLoopCounter = 5 Then pitchUp = False
If pitchLoopCounter = 10 Then pitchUp = True


If pitchUp = True Then
pitch += 100
Else
pitch = pitch - 100
End If

txtLoopCounter.Text = pitchLoopCounter

Loop Until i = NumberOfTimes

btnBeepIt.Enabled = True
Else
MessageBox.Show("That number is too high!", _
"Well shucks")
End If

Monday, August 30, 2010

Monday, August 30th 2010

I'm going to redo and expand upon a tutorial from an O'Reilly book.

first things first, drag and drop the ToolStripContainer control onto the form.

Seriously, what is the point of the ToolStrpContainer?

Setting up the pubs database was quite hard, the tutorial wanted me to use visual studio, but I ended up just doing it with SQL server



Dim result As DialogResult = Dialog1.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
End
End If


A weird thing from the tutorial



Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim result As DialogResult = Dialog1.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
End
Else
e.Cancel = True
End If
End Sub


Why did this have to be set up separately? I am not really what is going on here but I am just going to do it and hope that it makes sense one day.

Apparently, VB.net has several templates, including an about-box template, and an explorer form. which has a built-in tree view. Cool beans.

Thursday, August 26, 2010

Thursday, August 26 2010

Finally got something to work


Dim conServer As SqlConnection = New SqlConnection("data source =ALFRED-PC\SQLExpress; initial catalog=database_Alfred; User ID=sa; password=china")
conServer.Open()

If conServer.State = ConnectionState.Open Then
lblConnection.Text = "SQLConnection is Open"

ElseIf conServer.State = ConnectionState.Closed Then
lblConnection.Text = "SQLConnection is closed"
End If


I'm going to full around with making my own projects, although I realized that I dutifully need to go back to tutorials as well.

I have a couple of projects that I want to work on:

1.) calculating salary, the percentage taken out by federal tax, the percentage taken out by state tax
-THEN- the cost of an item, the additional sales tax, and the percentage of your net income that it would take out

2.) calculating compound growth

I added a lblConnection.ForeColor = Color.Blue to the code above, which was nifty.

I modified my SQL DB with the following Transact-SQL code



USE database_Alfred
GO
CREATE TABLE investments
(
CompanyNumber int NOT NULL,
Ticker char(7) NOT NULL,
Name char(70) NOT NULL,
PurchasePrice int NOT NULL,
)


This was the first time for me to add a reference.

Wednesday, August 25, 2010

Wednesday, August 25 2010

I am trying to develop my own small app as a way of learning VB.

Right now I am focused on using ADO.NET to create a new record in a SQL Server DB using information taking from a VB windows application.



Imports System.Data.SQLClient


System.Data.SqlClient is a namespace.

I have to remember to right click and run visual studio as an administrator. Thank you Windows 7

Monday, August 23, 2010

Monday, August 23 2010

I wrote my first mini console application today. It was nothing impressive.

I took a look at the WebBrowser Control which is very cool.

I also reviewed some rudiments of Visual Basic using LearnVisualStudio.Net which is an alright site.

Friday, August 20, 2010

Friday, August 20 2010

The simplified syntax of the SELECT statement



SELECT select_list
FROM table_source
[WHERE search_condition]
[ORDER BY order_by_list]

Thursday, August 19, 2010

Thursday, August 19th, 2010

Today I am going to take a look at SQL server (hopefully) using yet another tutorial using Murach - (). They do make excellent books, although I felt (feel) that the VB book "jumps" a bit.

Client/Server System - has three parts, a client which I would call the user terminal (?) that is basically a PC in most cases, the Database server and the Network itself, cables, routers, etc.

(LAN) and (WAN) - one is a local area network, the other is a wide area network.

SQL stands for Structured Query Language and apparently you can pronounce it "S-Q-L" if you wish.

Back-end processing versus front-end processing - back-end processing is done by the database management system, whereas front-end processing is done by the application software.

Columns are vertical (like columns in a building) and rows are horizontal.

A foreign key is one (or more) column in one table that refers to a column in another table.

The most common data manipulation language (DML) SQL statements are SELECT,INSERT,UPDATE, and DELETE.

The most common data definition language(DDL) SQL statements are CREATE DATABASE, CREATE TABLE, CREATE INDEX, ALTER TABLE, DROP DATABASE, DROP TABLE, DROP INDEX