It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

I desperately need help with a problem

Moderator: dafunkymunky

I desperately need help with a problem

Postby jmvhbassist on Wed Oct 07, 2009 6:23 pm

Someone is hired for a job and agrees to pay one penny for the first day, two pennies for the second day, four pennies for the third day, and continuing to double each day. I need an application that allows the user to select/enter from a combo box the number of days the person will work and calculates the total pay.
jmvhbassist
 
Posts: 1
Joined: Wed Oct 07, 2009 6:15 pm

Re: I desperately need help with a problem

Postby pachecf on Fri Oct 09, 2009 12:10 am

This is simple:

1. add a combo box to your form (combobox1)
2. double click your form and add the following to the form load event

'This will add the numbers from 1 to 100 to the combo box for selection
For x = 1 To 100
ComboBox1.Items.Add(x)
Next

3. add a text box (TextBox1) to your form
4. double click on your combobox1 control and add the following script to the ComboBox1_SelectedIndexChanged event

Dim x, y, z As Integer
x = ComboBox1.Text
x = x - 1
If x >= 2 Then
z = 1
For y = 1 To x
z = z * 2
Next
ElseIf x = 0 Then
z = 1
ElseIf x = 1 Then
z = 2
End If
TextBox1.Text = z

5 Test it !
pachecf
 
Posts: 6
Joined: Thu Oct 08, 2009 8:18 pm


Who is online

Users browsing this forum: No registered users and 4 guests