none
How can I add "ft" to a number? RRS feed

  • Question

  • Hi -

    I have written a program to get the size of an area.  One line is:

    TextWindow.Write("Enter hor: ")       This asked me to enter one dimension of the area.  I want to add "ft" after the number to designate I'm measuring in feet.  Another line is:

    TextWindow.WriteLine("The area is: " + Area + ".")        After the number is printed I want to add "sqft" to the number.     Can someone help?  I can submit the entire program if that would help.    Thanks     Bob

    Wednesday, February 12, 2014 3:12 PM

Answers

  • You have a " to much in the WriteLines:

    "hor = "+hor+"  "ft"

    ------------^

    You should have  text        "hor = "    +

                          variable      hor         +

                           text         "ft"


    Jan [ WhTurner ] The Netherlands

    • Marked as answer by bobhlgh Friday, February 14, 2014 1:12 PM
    Friday, February 14, 2014 10:47 AM
    Answerer
  • Jan -

    Thanks for all your time.  I will now mark this as done.    Bob

    • Marked as answer by bobhlgh Friday, February 14, 2014 1:12 PM
    Friday, February 14, 2014 1:12 PM

All replies

  • You can always add the sqft in the WriteLine("The area is: "+Area+". sqft"). Or do you want to adapt the output to the measuringunit of the input?

    Jan [ WhTurner ] The Netherlands

    Wednesday, February 12, 2014 3:57 PM
    Answerer
  • Thanks for the reply.  What you suggested worked just fine when I used it with "Area".  However when I tried to put "ft" after     Window.Write("Enter hor.")

    it put the "FT" first then put the value of hor. I hope I have made my meaning clear.

    Thanks    Bob  

    Wednesday, February 12, 2014 10:18 PM
  • Are you trying to put "ft" to the right of where the user will type? That could be done, but not very cleanly. A much easier solution would be:

    TextWindow.Write("Enter hor (ft): ")


    Please mark any answers and "vote as helpful" any posts that help you!

    Wednesday, February 12, 2014 11:44 PM
    Answerer
  • The method you can use to place ft behind the place to enter the amount:

    For i=1 To 9
      back=back+Text.GetCharacter(8)    'backspace character
    EndFor
    
    TextWindow.Write("enter hor:         ft"+back)
    x=TextWindow.Read()
    TextWindow.WriteLine(x)


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Thursday, February 13, 2014 10:32 AM explanation char 8
    Thursday, February 13, 2014 10:26 AM
    Answerer
  • You can put the next lines before the label mid:

    Textwindow.Clear()

    Textwindow.WriteLine("Hor = "+hor+" ft")

    Textwindow.WriteLine("Ver = "+ver+" ft")

    I think you should also give an explanation why there are 5 answers.


    Jan [ WhTurner ] The Netherlands


    Thursday, February 13, 2014 6:13 PM
    Answerer
  • Hi -

    I put the lines in as I understood but I got errors.

    TextWindow.Write("Enter hor:  ")
    hor =TextWindow.Read()
    TextWindow.Write("Enter ver:  ")
    ver = TextWindow.Read()
    TextWindow.Clear()
    TextWindow.WriteLine("hor = "+hor+"  "ft")
    TextWindow.WriteLine("ver = "+ver+"  "ft")
    Mid:
    Area = hor * ver
    TextWindow.WriteLine("The area is:  "   +   Area  +  " sqft.")
    If (hor < 10) Then
    hor = hor + 2
    Goto Mid
    Endif

    6.41 Encountered unexpected end of line parsing method call

    7.41  repeated above

    6.12 Operation 'TextWindow.WriteLine' is supplied 3 arguments, but takes only 1 argument.

    7.21   repeated above

    What did I do wrong?

    Thursday, February 13, 2014 8:43 PM
  • Hi -

    The reason I got 5 answers:  The program finds the area of a rectangle when you change the size of one side.  In this case I am changing the hor side by 2 ft each time the program loops.   Thanks for your time.      Bob 

    Thursday, February 13, 2014 8:51 PM
  • You have a " to much in the WriteLines:

    "hor = "+hor+"  "ft"

    ------------^

    You should have  text        "hor = "    +

                          variable      hor         +

                           text         "ft"


    Jan [ WhTurner ] The Netherlands

    • Marked as answer by bobhlgh Friday, February 14, 2014 1:12 PM
    Friday, February 14, 2014 10:47 AM
    Answerer
  • Jan -

    Thanks for all your time.  I will now mark this as done.    Bob

    • Marked as answer by bobhlgh Friday, February 14, 2014 1:12 PM
    Friday, February 14, 2014 1:12 PM