Ask Experts Questions for FREE Help !
Ask
    panderso's Avatar
    panderso Posts: 2, Reputation: 1
    New Member
     
    #1

    Apr 25, 2008, 01:40 PM
    If statement
    Hi I am doing this simple program in visual basic express

    Sum.Text = Val(Num1.Text * 3) + Val(Num2.Text) + Val(Num3.Text) - Val(Num3.Text)

    This allows the user to enter number of wins (which gets x by 3) number of draws and number of losses.

    I have to limit the user to entering a combination of only 10 i.e 4 wins 3 draws 3 lose.

    I have been trying to put an it statement in that will prompt user to check input if they enter a combination of less or more than 10, any help would be great.

    I hope this makes sense.

    Thanks fr looking:)
    Scleros's Avatar
    Scleros Posts: 2,165, Reputation: 262
    Hardware Expert
     
    #2

    Apr 25, 2008, 05:22 PM
    My Basic is rusty, but the general idea would be:

    Code:
    Do (Forever)
      Wins = InputBox(Wins)
      Draws = InputBox(Draws)
      Losses = InputBox(Losses)
    
      If (Wins + Draws + Losses) <> 10 Then
        MessageBox "Stupid User!"
      Else
        Sum = Wins*3 + Draws + Losses - Losses (Your code?)
        
        Exit Do
      End If
    Loop
    
    [Use Sum]
    melondotnet's Avatar
    melondotnet Posts: 23, Reputation: 1
    New Member
     
    #3

    Apr 29, 2008, 12:44 PM
    It may be better to create a system by which the user can not procede without entering the correct num of things, by having a continue button disabled.
    Form:

    Imaging you have three text boxes, and a continue button.

    txtWins as textbox
    txtLoses as textbox
    txtDraws as textbox
    next as button [auto disabled on form load]

    Code:


    Private Sub Input_Change(ByVal sender... ) Handels txtWins.TextChanged, txtLoses.TextChanged, txtDraws.TextChanged 'Revise this, It may not be accurate!

    'If the text in any of the text boxs changes, run a CHECK
    'The Handeling code may not be accurate. I havn't had multiple handle events leading to the same outcome for a long time.

    Check_10()

    End Sub

    Sub Check_10()

    If Cint(txtWins.text) + Cint(txtLoses.Text) + Cint(txtDraws.Text) = 10 Then
    'If inputs add up to 10, enable the continue button
    next.Enabled = True
    Else
    'If inputs add up to something over than 10, disable it
    next.Enabled = False
    End If

    End Sub

    :End Code

    Hope this helps

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Multiple-step income statement in good form and retained earnings statement [ 1 Answers ]

Hi I would like someone to check to see if I did this correctly, if I did not then please help. Thanks The Problem is: The following pretax amounts pertain to River Corp. for the year ended December 31, 2008. Sales... $400,000 Operating Expenses... 84,000 Extraordinary gain... 30,000...

Income statement, owners equity statement and balance sheet [ 6 Answers ]

Les Fleurs, a boutique in Paris, France, had the following accounts in its accounting records at December 31, 20X2 (amounts in Euros, denoted as "E") Purchases………………... E250,000 Freight In……………… E8,000 Sales discounts…………. 4,000 Purchase returns…….. 7,000 Inventory Sales…………………. ...

Financial Statement with Balance sheet and income statement [ 1 Answers ]

Here's the problem: The Hobart Company incurred the following transactions during 2003: A. Acquired $50,000 of cash capital from owners B. Paid $10,000 to acquire manufacturing equipment C. Paid $5,000 cash for materials used in production D. Paid $2,000 for wages of production workers...

What is the correct financial statement-statement of cash flows wording? [ 2 Answers ]

Cash (used) in operating activities <10,000> Cash (used) in investing activities 10,000 Thank you for any help you can provide.

Prepare income statement and retained earning statement [ 1 Answers ]

The following information was taken from the 2004 financial statement of pharmecutical giant Merck and CO. All dollar amounts are in millions. Retained earnings, January 1, 2004 34,142.0 Materials and production expense 4,959.8 Marketing and administrative expense 7,346.3 Dividends 3,329.1...


View more questions Search