Results 1 to 3 of 3

Thread: V 2010

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    40

    V 2010

    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.

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: V 2010

    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:
    1. Use the InputBox method (strongly not recommended)
    2. Use two labels and two textboxes, then valid the entries in each TextBox to ensure that they are indeed numbers, then calculate the percentage
    3. Create a custom Form that acts as an input box - probably excessive

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: V 2010

    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:
    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)
    This is really simple stuff. Anyhow, ask if you don't understand something.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width