How do you put an input box in your form? I need it to ask 2 questions that will output a percentage rate.
It is a project that gives the percentatage rate of available hotel rooms.
Printable View
How do you put an input box in your form? I need it to ask 2 questions that will output a percentage rate.
It is a project that gives the percentatage rate of available hotel rooms.
The first step is to use a descriptive title for your thread. Secondly, you don't 'put' an input box in your Form.
There are a few options to "ask a question" as it is:
- Use the InputBox method (strongly not recommended)
- Use two labels and two textboxes, then valid the entries in each TextBox to ensure that they are indeed numbers, then calculate the percentage
- Create a custom Form that acts as an input box - probably excessive
As already mentioned.
1. Put two TextBox-es on your Form and one Button on your Form.
2. Name the first TextBox "txtA" and the second one "txtB".
3. Double click on the Button. Code editor should open. Paste this code in there:This is really simple stuff. Anyhow, ask if you don't understand something.Code:Dim decA As Decimal
Dim decB As Decimal
Dim decPrecentage As Decimal
Try
decA = Convert.ToDecimal(Me.txtA.Text)
decB = Convert.ToDecimal(Me.txtB.Text)
Catch
MessageBox.Show("Please enter two valid numbers.")
Return
End Try
decPrecentage = decA + decB ' ? do your thing here
MessageBox.Show(decPrecentage)