Visual Basic Programming

Discussion in 'OT Technology' started by Beautiful One, Mar 30, 2005.

  1. I am writing a program that will convert liters into pints and gallons. I am having a problem with the results displaying when I enter the amount of liters rather than after clicking the "convert" button. I am not sure what I have done wrong and I have been researching for hours with no luck on fixing the issue. Maybe someone here can point me in the right direction as to how display the results only after I click the "convert" button.
     
  2. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    What action do you have the conversion method associated with? If it's a ButtonClick method, then it should work fine :dunno:
     
  3. This is my first programming class so I am not sure that I understand what you are asking but this is where I have the results coded.

    Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
    pintAmt.Text = (literAmt.Text * 2.1134)

    galAmt.Text = (literAmt.Text * 0.2642)

    End Sub

     
  4. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    It looks like your button code is fine, I'd assume that when you press the "Convert" button it performs the calculation as well? What you want to look at is the code for the pintAmt field. You can double-click the field itself which should open the code window.

    On the upper right it should show all the possible actions (click, focus, enter, etc.). Scroll through that list and look for anything that is bold (bold means there is code for that action), click on the bold action and remove or comment that code out.

    Cliffs:

    Your button is fine.
    The pintAmt textbox is suspect.
     
  5. The calculation performs when I enter the liter amount not when I click the "Convert" button. This is the problem I want the results to display only when I click the "Convert" button.
     
  6. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Sounds like your gallon box is NOT unbound, which is should be.
     
  7. I figured out what the problem was. Not only did I code the "Convert" button, I also coded the pintAmt and galAmt text boxes to display the calculations. I deleted the code and everything worked out. It seems like over did the coding.
     
  8. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    So, I was right? W00t!
     
  9. I wasn't sure what you meant by unbound. I was looking for a property. But now I understand. I basically told the program to automatically display the results by coding the text boxes?
     
  10. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    Noo.. I was right and she just doesn't know that if she listened to me she'd have been done yesterday. :mamoru:

    Though you kinda said the same thing after me so I give you half credit :hug:
     
    Last edited: Mar 31, 2005
  11. First of all I am a she. Second of all thanks for the advice, I missed the "remove" part.:uh: By this time I was already pissed off and frustrated I needed to walk away from it. This is the first program I have written using VB or any language for that matter.
     
  12. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH

    Edited for she :) My apologies.
     
  13. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Actually, I was right too, just more vague than either of you since I haven't used VB in a long time :mamoru:
     

  14. :) No problem.
     

Share This Page