Public Class Form1
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As Byte(), ByVal hmod As Integer, ByVal flags As Integer) As Integer
Dim apples As New List(Of PictureBox)
'Dim apple As PictureBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim txt As TextBox
'For i = 0 To 9
' txt = New TextBox
' txt.BackColor = Color.AliceBlue
' txt.Location = New Point(100, i * 50)
' Me.Controls.Add(txt)
' txtboxes(i) = txt
'Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For Each apple In apples
' check if apple hit the ground
If apple.Location.Y + apple.Size.Height >= theGround.Location.Y Then
' play a sound
' remove the item and penalize the player
removeAnApple(apple)
Label1.Text = Label1.Text - 500
Exit For
Else
' animate it
apple.Location = New Point(apple.Location.X, apple.Location.Y + 4)
End If
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PlaySound("C:\Users\Public\Music\Sample Music\Kalimba.mp3", 1, 0)
addAnApple()
Timer1.Enabled = True
End Sub
Sub removeAnApple(ByVal apple As PictureBox)
Me.Controls.Remove(apple)
apples.Remove(apple)
End Sub
Private Sub apple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
removeAnApple(sender)
Label1.Text = Label1.Text + 100
addAnApple()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
addAnApple()
End Sub
Sub addAnApple()
Dim r As New Random
Dim apple As PictureBox
apple = New PictureBox
' Me.Width(-90)
apple.Location = New Point(r.Next(0, Me.Width - 90), 12)
apple.ImageLocation = "C:\Users\joshwaxman.CSDEPT.000\Pictures\APPLE.jpg"
apple.SizeMode = PictureBoxSizeMode.StretchImage
apple.Size = New Point(90, 90)
AddHandler apple.Click, AddressOf apple_Click
Me.Controls.Add(apple)
apples.Add(apple)
End Sub
End Class
Thursday, July 29, 2010
Wednesday, July 28, 2010
Public Class Form1
Dim txtboxes(9) As TextBox
Dim apple As PictureBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim txt As TextBox
'For i = 0 To 9
' txt = New TextBox
' txt.BackColor = Color.AliceBlue
' txt.Location = New Point(100, i * 50)
' Me.Controls.Add(txt)
' txtboxes(i) = txt
'Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' animate!
If apple IsNot Nothing Then
apple.Location = New Point(apple.Location.X, apple.Location.Y + 4)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
addAnApple()
Timer1.Enabled = True
End Sub
Private Sub apple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Controls.Remove(apple)
apple = Nothing
Label1.Text = Label1.Text + 100
addAnApple()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
addAnApple()
End Sub
Sub addAnApple()
Dim r As New Random
apple = New PictureBox
' Me.Width(-90)
apple.Location = New Point(r.Next(0, Me.Width - 90), 12)
apple.ImageLocation = "C:\Users\joshwaxman.CSDEPT.000\Pictures\APPLE.jpg"
apple.SizeMode = PictureBoxSizeMode.StretchImage
apple.Size = New Point(90, 90)
AddHandler apple.Click, AddressOf apple_Click
Me.Controls.Add(apple)
End Sub
End Class
Dim txtboxes(9) As TextBox
Dim apple As PictureBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim txt As TextBox
'For i = 0 To 9
' txt = New TextBox
' txt.BackColor = Color.AliceBlue
' txt.Location = New Point(100, i * 50)
' Me.Controls.Add(txt)
' txtboxes(i) = txt
'Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' animate!
If apple IsNot Nothing Then
apple.Location = New Point(apple.Location.X, apple.Location.Y + 4)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
addAnApple()
Timer1.Enabled = True
End Sub
Private Sub apple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Controls.Remove(apple)
apple = Nothing
Label1.Text = Label1.Text + 100
addAnApple()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
addAnApple()
End Sub
Sub addAnApple()
Dim r As New Random
apple = New PictureBox
' Me.Width(-90)
apple.Location = New Point(r.Next(0, Me.Width - 90), 12)
apple.ImageLocation = "C:\Users\joshwaxman.CSDEPT.000\Pictures\APPLE.jpg"
apple.SizeMode = PictureBoxSizeMode.StretchImage
apple.Size = New Point(90, 90)
AddHandler apple.Click, AddressOf apple_Click
Me.Controls.Add(apple)
End Sub
End Class
insertion sort
for pos = 0 to UBound(A)
val = A(pos)
for j = pos - 1 to 0 Step -1
if val < A(j) then
A(j+1) = A(j)
else
exit for
endif
next j
A(j+1) = val
next pos
val = A(pos)
for j = pos - 1 to 0 Step -1
if val < A(j) then
A(j+1) = A(j)
else
exit for
endif
next j
A(j+1) = val
next pos
Tuesday, July 27, 2010
Public Class Form1
Dim txtboxes(9) As TextBox
Dim WithEvents apple As PictureBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim txt As TextBox
For i = 0 To 9
txt = New TextBox
txt.BackColor = Color.AliceBlue
txt.Location = New Point(100, i * 50)
Me.Controls.Add(txt)
txtboxes(i) = txt
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' animate!
PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y + 4)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
PictureBox1.Visible = False
Label1.Text = Label1.Text + 100
End Sub
Private Sub apple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles apple.Click
MessageBox.Show("hello")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
apple = New PictureBox
apple.Location = New Point(284, 12)
apple.ImageLocation = "C:\Users\joshwaxman.CSDEPT.000\Pictures\APPLE.jpg"
apple.SizeMode = PictureBoxSizeMode.StretchImage
apple.Size = New Point(90, 90)
Me.Controls.Add(apple)
End Sub
End Class
Dim txtboxes(9) As TextBox
Dim WithEvents apple As PictureBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim txt As TextBox
For i = 0 To 9
txt = New TextBox
txt.BackColor = Color.AliceBlue
txt.Location = New Point(100, i * 50)
Me.Controls.Add(txt)
txtboxes(i) = txt
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' animate!
PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y + 4)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
PictureBox1.Visible = False
Label1.Text = Label1.Text + 100
End Sub
Private Sub apple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles apple.Click
MessageBox.Show("hello")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
apple = New PictureBox
apple.Location = New Point(284, 12)
apple.ImageLocation = "C:\Users\joshwaxman.CSDEPT.000\Pictures\APPLE.jpg"
apple.SizeMode = PictureBoxSizeMode.StretchImage
apple.Size = New Point(90, 90)
Me.Controls.Add(apple)
End Sub
End Class
Thursday, July 22, 2010
Wednesday, July 14, 2010
Thursday, July 8, 2010
Thursday, July 1, 2010
Exercise 1: compute the sum of two numbers supplied by the user, and display the result in a listbox:
Exercise 2: compute the sum and product of two numbers supplied by the user, and display the result in a listbox(Note: when you click button “Compute Product”, the product of the two numbers should be displayed in textbox “Product”, and nothing in “Sum:”, and vice versa, if you want to compute the sum, the result should be displayed in “Sum:”, but nothing in “Product” ):
Subscribe to:
Posts (Atom)