



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' use the penny variable to compute money as a decimal value Dim penny As Single ' number of times to double a penney and the loop index Dim numtimes, counter As Integer
' initialize to the value of a single penney penny = 0. numtimes = CInt(TextBox1.Text)
For counter = 1 To numtimes Step 1 penny = penny * 2 Next
' Show the result Label2.Text = "Result: " & Format(penny, "c") End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' use the penny variable to compute money as a decimal value Dim penny As Single ' Goal amount to achieve by doubling Dim goal As Single ' number of times the penny was doubled Dim numtimes As Integer
' initialize the value of a single penny and the number penny = 0. numtimes = 0 ' Get the Goal amount from the user goal = CSng(TextBox1.Text)
While penny < goal penny = penny * 2 numtimes = numtimes + 1 End While
' Show the result Label2.Text = "Number of times doubled: " & CStr(numtimes) End Sub