# range

  1. #1
    Banned Reputation: 15

    Join Date
    Aug 2006
    Posts
    1,037
    Rep Power
    0

    Default # range

    what do i put in the source code so that for example: value 0-4.4 will only work in a textbox when entered? Im learning visual basic.net atm... The book i am using is probably known by alot... "An introduction to Programming" --->Lawrenceville Press~ If you have it its 4-24, exercise1. The question is:

    The height of an object at any given time dropped from a starting height of 100meters is given by the equation h=100-4.9*t[2] where t is the time in seconds. Create an object height application that prompts the user for a time less than 4.5 seconds and then displays the height of the object at that time when Height is clicked. The application should look similar to:
    .... well you cant see it since its in the book, but thats the question anyways.
    Last edited by Inugami; 09-26-2006 at 11:00 PM.

  2. #2
    Crumbly, yet Good Reputation: 75
    Eriond's Avatar
    Join Date
    May 2006
    Location
    Montreal
    Posts
    1,798
    Rep Power
    0

    Default

    Do you want them not to be able to enter it, or do you want a message box to pop up when they click ok, saying that they must enter a number between 0 - 4.4?
    THIS MA SIGNATURE

  3. #3
    Luigiís Pizza Reputation: 10

    Join Date
    Jul 2006
    Posts
    145
    Rep Power
    9

    Default

    I dont understand your question either.

  4. #4
    Banned Reputation: 15

    Join Date
    Aug 2006
    Posts
    1,037
    Rep Power
    0

    Default

    could you show me both please? I really want to know

    Quote Originally Posted by FlawedSin View Post
    I dont understand your question either.
    Im asking how do i make it so that you can only enter/calculate if the value entered in the textbox is 0 to 4.4
    Last edited by Inugami; 09-26-2006 at 11:39 PM.

  5. #5
    Crumbly, yet Good Reputation: 75
    Eriond's Avatar
    Join Date
    May 2006
    Location
    Montreal
    Posts
    1,798
    Rep Power
    0

    Default

    Lol, well... I've never used VB, but I have worked with the Win32 API...

    So, I only know how to do the messagebox one.

    First, get the value from the textbox (GetWindowText in C), and then convert it to a float (atof in C). Then check if


    float var = atof(string);
    if ( var > 0.0f && var <= 4.4 )
    <Actions>
    else
    MessageBox(<Window Handle>,<App Name>,"You must enter a value between 0.0 and 4.4!", MB_OK);

    That's how I'd do it in C. Hope that helps you. It should be similar in VB.
    THIS MA SIGNATURE

  6. #6
    Banned Reputation: 15

    Join Date
    Aug 2006
    Posts
    1,037
    Rep Power
    0

    Default

    well its a lil complicated but i can understand some parts of that.

  7. #7
    Luigiís Pizza Reputation: 10

    Join Date
    Jul 2006
    Posts
    145
    Rep Power
    9

    Default

    why not just do this

    when you click there have it check if

    If NUMBER < 4.5 Then

    NUMBER is the variable you have it set it to.

    Then it checks if your number is from 4.4 to 0.

  8. #8
    Crumbly, yet Good Reputation: 75
    Eriond's Avatar
    Join Date
    May 2006
    Location
    Montreal
    Posts
    1,798
    Rep Power
    0

    Default

    That's basically what I said, but it's a bit more complciated than that, because message box stuff is in the format of a character string, so it has to be converted. But yeah, absicaly that's it.
    THIS MA SIGNATURE

  9. #9
    Luigiís Pizza Reputation: 10

    Join Date
    Jul 2006
    Posts
    145
    Rep Power
    9

    Default

    no making a message box is pretty simple in VB

    im not sure whats all different in .net but I think they are similar

    if you want to know how to make a message box let me know and I will post the code

Posting Permissions

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