Monday, October 4, 2010

Monday, October 4th 2010

I'm going to be continuing to work on the Halvorson tutorials. I am comfortable working with the tutorials that Michael Halvorson has designed, they're fun, they're well paced and build on each other(I think the word I am looking for is they are incremental?)

array.sort
array.find
array.reverse
array.copy
array.clear

According to Halvorson, these are the most useful methods for dealing with arrays.



Public Class Form1

Dim RandArray(0 To 499) As Long

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

ProgressBar1.Minimum = 0
ProgressBar1.Maximum = UBound(RandArray)
lblCounter.Text = UBound(RandArray) + 1

End Sub

Private Sub txtDisplay_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDisplay.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
txtDisplay.Text = ""
For i = 0 To UBound(RandArray)
RandArray(i) = Int(Rnd() * 1000000)
txtDisplay.Text = txtDisplay.Text & RandArray(i) & vbCrLf
ProgressBar1.Value = i
Next
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i As Integer
txtDisplay.Text = ""
Array.Sort(RandArray)
For i = 0 To UBound(RandArray)
txtDisplay.Text = txtDisplay.Text & RandArray(i) & vbCrLf
ProgressBar1.Value = i
Next
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim i As Integer
txtDisplay.Text = ""
Array.Sort(RandArray)
Array.Reverse(RandArray)
For i = 0 To UBound(RandArray)
txtDisplay.Text = txtDisplay.Text & RandArray(i) & vbCrLf
ProgressBar1.Value = i
Next
End Sub
End Class


I also worked with a tutorial written by Anne Boehm



Dim numbers(10) As Integer
For i As Integer = 0 To numbers.Length - 1
numbers(i) = i
Next

Dim numbersString As String = ""
For i As Integer = 0 To numbers.Length - 1
numbersString &= numbers(i).ToString & vbCrLf
Next
TextBox1.Text = numbersString

Dim sum As Decimal
For i As Integer = 0 To numbers.Length - 1
sum += numbers(i)
Next
Dim average As Decimal = sum / numbers.Length
TextBox1.Text = TextBox1.Text + "The average is: " & average.ToString


Here is a tutorial by Patrice Pelland that I modified a little


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.lblApplicationStatus.Text = "Ready"
WebBrowser.Navigate("about:blank")

End Sub

Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
Dim address As String = txtAddress.Text
Me.lblApplicationStatus.Text = "Waiting for: " + address
WebBrowser.Navigate(address)

End Sub

Private Sub WebBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser.DocumentCompleted

If ((Not (WebBrowser.IsBusy)) And (WebBrowser.ReadyState = WebBrowserReadyState.Complete)) Then
If My.Application.Info.Title <> "" Then
Me.Text = My.Application.Info.Title + " - " +
e.Url.Host.ToString()
Else
Me.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) + " - " +
e.Url.Host.ToString()
End If
Me.lblApplicationStatus.Text = "Ready"
End If
End Sub

Private Sub WebBrowser_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser.ProgressChanged
If e.CurrentProgress < e.MaximumProgress Then
If pbStatus.Value >= pbStatus.Maximum Then
pbStatus.Value = pbStatus.Minimum
Else
pbStatus.PerformStep()
End If
Else
pbStatus.Value = pbStatus.Minimum
End If
End Sub

No comments: