Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim adds As Double
Dim int, num As Integer
adds = CDbl(TextBox1.Text)
num = 0
For int = 1 To adds
num = num + 1
ListBox1.Items.Add(num)
Next
End Sub
End Class
2.)If you were to put away a certain amount of money every month, how many years would it take you to save up $10,000. Use a textbox to gather the amount that is to be put away every month. Use a label to display the number of years it would take.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intPay As Integer = CInt(TextBox1.Text)
Dim intGoal As Integer = 10000
Dim intMonths, intTotal As Integer
Dim decYears As Decimal
intPay = CInt(TextBox1.Text)
intGoal = 10000
For intTotal = 1 To intGoal
intTotal += intPay
intMonths = intMonths + 1
decYears = intMonths / 12
Label1.Text = (decYears.ToString & " years")
Next
End Sub
End Class
3.) Write a program that will create a times table.
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20 …..
10 20 30 40…..
You could use labels or buttons to hold the numbers. Generate these dynamically and add them to the Me.Controls collection.
You will have to use two loops, one inside of the other to get this to work.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim c, d As Integer
c = 1
Button1.Visible = False
For c = 1 To 10
For d = 1 To 10
Dim multibutton As New Button
multibutton.Location = New Point(70 * c, 30 * d)
multibutton.Width = 40
multibutton.Text = c * d
Me.Controls.Add(multibutton)
Next
Next
End Sub
End Class
No comments:
Post a Comment