Friday, October 22, 2010

Friday, October 22 2010

This isn't really that fancy, but I mostly did it on my own. I am populating a textbox with more textboxes, where the textboxes location is being determined randomly. I like it.


Public Class Form1

Dim arrayName(1000) As String
Dim index As Integer = 0


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
playingField.Width = 1200
playingField.Height = 800
playingField.Left = ClientRectangle.Left + 7

Randomize()
Dim x As Integer
Dim y As Integer
Dim MyNewTextbox As New TextBox


x = (Int(Rnd() * 1150)) + playingField.Left + 3
y = (Int(Rnd() * 750)) + playingField.Top + 3

arrayName(index) = "Box" & index




index += 1
MyNewTextbox.Size = New Size(20, 20)
MyNewTextbox.Text = "0"
MyNewTextbox.Location = New Point(x, y)
MyNewTextbox.ForeColor = Color.White
MyNewTextbox.BackColor = Color.Black
MyNewTextbox.BorderStyle = BorderStyle.None
MyNewTextbox.Name = arrayName(index)

If arrayName(index) = "box5" Then
MyNewTextbox.ForeColor = Color.Red

End If

If index Mod 7 = 1 Then
MyNewTextbox.ForeColor = Color.Green
End If

Me.Controls.Add(MyNewTextbox)
MyNewTextbox.BringToFront()





End Sub

Private Sub playingField_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles playingField.TextChanged

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 0 To 1000
arrayName(i) = "box" & i
Next i

End Sub
End Class




Dim Message As String
Select Case Now.DayOfWeek
Case DayOfWeek.Monday
Message = "Have a nice week"
Case DayOfWeek.Friday
Message = "Have a nice weekend!"
Case Else
Message = "Welcome back!"

End Select

'' I added a title to the message box, I've done it before from tutorials but couldn't remeber how to do it off the top of my head.

MsgBox(Message, 0, "Title")


End Sub
End Class


These tutorials are from Evangelos Petroutsos

''The IndexOf method locates an instance of a character in a string


Dim MyText As String
MyText = "The quick brown fox jumped over the lazy dog."
Dim position, words As Integer
position = 0 : words = 0
Do While position >= 0
position = MyText.IndexOf(" ", position + 1)
words += 1
Loop
MsgBox("There are " & words & " words in the text.")



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

'' Pmt() is a built-in function for figuring out payments

Dim mPay, totalPay As Double
'' I edited this to allow the end user to put some of their own information
Dim years As Integer
Dim months As Integer

years = InputBox("How many years will you be paying the loan?")
months = monthlyOrNot()
MsgBox(months)
Dim Duration As Integer = months * years
Dim Rate As Single = (7.25 / 100) / 12
Dim Amount As Single = 20000
mPay = -Pmt(Rate, Duration, Amount)
totalPay = mPay * Duration
MsgBox("Each payment will be " & mPay.ToString("C") & vbCrLf & "You will pay back a total of " & totalPay.ToString("C"))




End Sub
Public Function monthlyOrNot()
If MsgBox("Will you be paying monthly?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Return 12
ElseIf MsgBox("Will it be quarterly?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Return 4
ElseIf MsgBox("Will the payment be bimonthly?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Return 6
Else
Return 1
End If
End Function

No comments: