Results 1 to 9 of 9

Thread: Loop without Do?

  1. #1
    Guest
    What does Loop without Do mean in this context??

    Loop While FTemp <> ""

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    You have to have a do statement at the beginning of your loop and the Loop While statement at the end.

    Code:
    Do
     ' your code here
    Loop While ftemp <> ""
    Looks like a neverending loop to me though, be careful!
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3
    Guest
    Prompt = "Enter a Farenheit temperature."
    If FTemp <> "" Then
    Celcius = Int((FTemp + 40) * 5 / 9 + 40)
    MsgBox (Celsius), , "Temperature in Celcius"
    End If
    Loop While FTemp <> ""

    This is the code I have, the book has the code that way, aaarrrggghhh!

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Talking eeeessh!

    What book is that!???

    is there more to that code? that wont work at all!
    Code:
    'there is no use for prompt...like an InputBox
    'there is no DO for this loop!
    Prompt = "Enter a Farenheit temperature." 'Ok...but where do I enter it!!! :)
    If FTemp <> "" Then 
    Celcius = Int((FTemp + 40) * 5 / 9 + 40) 
    MsgBox (Celsius), , "Temperature in Celcius" 
    End If 
    Loop While FTemp <> ""

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Try This instead..

    Code:
    Do
    Prompt = "Enter a Farenheit temperature."
    FTemp = InputBox(Prompt)
    If FTemp <> "" Then
    Celcius = (Int(FTemp) + 40) * 5 / 9 + 40
    MsgBox Str(Celcius), , "Temperature in Celcius"
    End If
    Loop While FTemp <> ""
    If that is how the code is in the book, find the closest source of fire and burn it!
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    I'm sure you're lost the Do in somewhere else. 'coz loop will not be able to work if Do syntax is not there.

    Chris

  7. #7
    Guest
    Geoff,

    This is the VB 6 book by Microsoft... Michael Halvorson

    Talk about annoying the amount of errors and here I am, sorta getting the hang of it and then I get totally floored by something that makes no sense at all!

    I'll try your suggestion and thanks!

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Command1_Click()
    Dim prompt As String
    
    prompt = "Enter a Farenheit temperature."
    FTemp = InputBox(prompt, "Temp")
    If FTemp = "" Then
        Exit Sub
    Else
    
    'where this came from who could guess
    'this gives 32 R as 80 c when in fact it is 0
    Celcius = Int((FTemp + 40) * 5 / 9 + 40)
    
    'I don't know the exact formula its -32/.something
        
        MsgBox FTemp & " Farenheit = " & Celcius & " Temperature in Celcius"
    End If
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  9. #9
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    formula!

    I hadn't noticed the formula is wrong! Excelent work Microsoft!
    Code:
    Celcius = Int((FTemp + 40) * 5 / 9 + 40)
    should be

    Code:
    Celcius = Int((FTemp -32) * 5 /9)

    Code:
    Fahrenheit = Int((FTemp *9 /5)+32)

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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