Public Class Form1
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
Dim amount As Integer = txtValue.Text
For n As Integer = 1 To amount
ListBox1.Items.Add(n & "items")
Next
End Sub
End Class
#2 - How many years will it take to save up to a certain amount of money
Public Class Form1
Private Sub btnYears_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYears.Click
Dim payment As Integer = txtPayment.Text
Dim counter As Integer = 1
Dim amount As Integer
Dim goal As Integer = 10000
Dim years As Integer
Do While amount < goal
counter += 1
amount = payment * counter
Loop
years = counter / 12
MessageBox.Show(years & " Years")
End Sub
End Class
#3 - Create a Times table using a loop within a loop
Public Class Form1
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
Dim y As Integer
Dim x As Integer
For x = 1 To 10
For y = 1 To 10
Dim btn As New Button
btn.Location = New Point(35 * x, 35 * y)
btn.Height = 35
btn.Width = 35
Me.Controls.Add(btn)
btn.Text = (x * y)
Next
Next
End Sub
End Class
No comments:
Post a Comment